Using declaration expected to terminate after variable name RRS feed

  • Question

  • I'm attempting to create a TextFieldParser object to read a file delimited by vertical bars ("|") into Excel. There is a tutorial on how to complete almost this exact task at this link:

    Unfortunately, even when I directly copied the code to initialize the object into the VBA editor, it did not work, giving me a compile-time error that read 'Expected: end of statement' and moving my selection to the "As" keyword on the line. This would seem to indicate that the line should be terminated immediately after the variable name, which makes no sense. The line immediately below is the one from the tutorial, and beneath that is the one I am using:

    Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\TestFolder\test.txt")

    Using fileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(workDir + "\" + fileName + ".txt")

    I am using Microsoft VBA 7.1.

    Monday, July 1, 2019 8:40 PM


All replies