Consulting

Results 1 to 5 of 5

Thread: Solved: Trying to Remove Quotes in txt File

  1. #1
    VBAX Regular
    Joined
    Apr 2009
    Posts
    19
    Location

    Solved: Trying to Remove Quotes in txt File

    I am using the code below to remove quotes from a text file but it bombs out on the Red Highlighted section below.... Can someone help me


    Dim nLength     As Long
        Dim sData       As String
        Close #1
        'Get the file length.
        Open "\\addfile00\Groups\Billing\Dictionaries\Rejections.txt" For Binary As #1
        nLength = LOF(1)
        Close #1
        sData = Space(nLength)
        Open "\\addfile00\Groups\Billing\Dictionaries\Rejections.txt" For Binary As #1
        Get 1, 1, sData
        sData = Replace(sData,"""," ")
        nLength = Len(sData)
        sData = Replace(sData, "Press <Return> to continue, or press <F7><Q> to quit: " & vbCrLf, "")
        sData = Replace(sData, "COMPLETED" & vbCrLf, "")
        sData = Left(sData, Len(sData) - 2) & String(nLength - Len(sData), " ") & vbCrLf
        Put 1, 1, sData
        Close 1

  2. #2
    VBAX Regular
    Joined
    Jun 2007
    Posts
    69
    Location
    bconner,

    Try replacing """ with """" and I believe your code should work as you expect it to.

    Cheers,
    Ron McKenzie
    Windermere, FL
    (living in the huge shadow of a tiny rodent)

  3. #3
    VBAX Regular
    Joined
    Apr 2009
    Posts
    19
    Location
    Worked perfectly, thanks for the suggestion

  4. #4
    VBAX Regular
    Joined
    Jun 2007
    Posts
    69
    Location
    You're very welcome!

    P.S. If this closes the issue, please mark the thread Closed. You can do this by clicking on Thread Tools in the menu bar, above, selecting Mark Closed and clicking the Apply Actions button.

    Thanks,
    Last edited by RonMcK3; 05-06-2010 at 01:42 PM. Reason: Add P.S. re: Marking Closed
    Ron McKenzie
    Windermere, FL
    (living in the huge shadow of a tiny rodent)

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    For the future, consider using the ASCII value CHR(34) or a variable to represent this eg
    DQ = CHR(34)
    It can make you code more comprehensible than multiple """"" type strings.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •