ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping through text files in a folder (https://www.excelbanter.com/excel-programming/439040-looping-through-text-files-folder.html)

bluewatermist

looping through text files in a folder
 
Hi

I recently had help in reading the next line of a text file but I am now
having problems in looping through and reading and extracting information in
all of the text files in a specific folder.

The previous help was in reading and extracting on a specific file but i
can't seem to get the looping to work.

Can anyone help me please? Below is the title of my previous discussion.
Frederic

Read the next line in a text file
http://www.microsoft.com/communities...a= wsignin1.0



goshute

looping through text files in a folder
 
The untested code below should read through all text files in the
specified directory

Dim strFile As String
'Get first file
strFile = Dir("C:\MyFolder\*.txt")

'Begin Processing
Do While Not Trim(strFile) = ""
'Insert file proccessing here . . . . . .
'Get Next File
strFile = Dir()
Loop


Goshute

bluewatermist

looping through text files in a folder
 

thank you for the quick reply. It works perfectly

Frederic.

"goshute" wrote:

The untested code below should read through all text files in the
specified directory

Dim strFile As String
'Get first file
strFile = Dir("C:\MyFolder\*.txt")

'Begin Processing
Do While Not Trim(strFile) = ""
'Insert file proccessing here . . . . . .
'Get Next File
strFile = Dir()
Loop


Goshute
.



All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com