Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import .txt file (VBA XP)

    I am trying to read a comma delimited text file into a variables. I don't even know where to start. Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import .txt file (VBA XP)

    Look up the Open and Input statements in the VBA help, for example by typing Open or Input into the Immediate window and pressing F1.

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import .txt file (VBA XP)

    You can also look at the FileSystemObject, which may be a bit easier to work with, although it is more limited in the types of files you can use. To create objects of this type, set a reference to Microsoft Scripting Runtime.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Import .txt file (VBA XP)

    For the FileSystemObject, the "4guysfromrolla" site had an interesting article on the Read and ReadAll methods. There's a link to it in this old thread: Reading a text file to a variable (VB6).

    To give you a third approach, you could look at ADO (if you have not used ADO before, and don't plan to do any database programming, then never mind).

Posting Permissions

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