I am trying to create the first part of a module that will dynamically open any files I put in a particular directory. I have some code (that works)I will add later to manipulate the contents of each file once they are opened.
This code is opening all the files, but gives a run-time error '1004' error after the last file is opened. I cannot figure out how to stop the loop without the error.
Any suggestions appreciated.
Sub ListFiles()
F = Dir("T:\Test\Data\*.XLS"
Do While Len(F) > 0
F = Dir()
Workbooks.Open FileName:="T:\Test\Data\" & F
Loop
End Sub
:-I
Dennis
DennisNH@aol.com
I develop applications in Access, Excel, PowerPoint, FrontPage, Word to intranet site at work. Looking to go beyond macros into VBA, and then to VB6.
This code is opening all the files, but gives a run-time error '1004' error after the last file is opened. I cannot figure out how to stop the loop without the error.
Any suggestions appreciated.
Sub ListFiles()
F = Dir("T:\Test\Data\*.XLS"
Do While Len(F) > 0
F = Dir()
Workbooks.Open FileName:="T:\Test\Data\" & F
Loop
End Sub
:-I
Dennis
DennisNH@aol.com
I develop applications in Access, Excel, PowerPoint, FrontPage, Word to intranet site at work. Looking to go beyond macros into VBA, and then to VB6.