0

Firstly, im not sure if this is the correct location for a VBA question?
Please move if necassary.

This is my first major project using VBA - Ive previosuly used vb.net quite alot, and still adjusting to understand both, and the differences.

My question is:
I have a folder with at times none, and at others up to 10-20 .txt files.
i want to loop through each file, and read each line from the file.
I have predefined variables that i want to asssign each of these lines (according to the order of lines read)
But im not sure how to read the file line by line.
I did a quick Google search and found that if use:

Open (*FILENAME*) For Input As File
While Not EOF(File)
Line Input #File, textofline

Then it would do what i wanted, but i cant specify the name of the file, and only that it can be named:
"Serial_*.txt"
The asterisk being any number greater than one (*sigh*)

Is there a way i can loop through the files in the designated folder. and read them one by one, after which i use the variables that are assigned by each line of the text file, to input into my spreadsheet.

SOrry if this is confusing, but im stuck :(

Regards
James

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Gobble45
0

I worked this out, if anyone would like to see the code, just let me know.

Regards
Gobble

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.