We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,011 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Searching folder, and then writing each line of each file to an .xls file

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
6 Days
Discussion Span
1 Year Ago
Last Updated
2
Views
Gobble45
Light Poster
29 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

Regards
Gobble

Gobble45
Light Poster
29 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0820 seconds using 2.67MB