ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a Succession (https://www.excelbanter.com/excel-programming/392723-opening-succession.html)

bodhisatvaofboogie

Opening a Succession
 
Workbooks.OpenText FILENAME:= _
"C:\JDIS_FILES\PURGRPT_" & "*.jdis"


This opens the file in the directory I want to be opened. However my
question is:
If there are say 10 reports with that prefix and suffix in that direcory, is
there a way I can have a macro open the first one, then the next one, then
the next one etc. On down the line until the last one then stop?

Does that make sense?

joel

Opening a Succession
 

First = True
Do while (1)
if First = True then
MyFilename = Dir("C:\JDIS_FILES\PURGRPT_" & "*.jdis")
First = False
else
MyFileName = Dir()
end if

if MyFilename = "" then exit do
Workbooks.OpenText FILENAME:= MyFileName
loop

"bodhisatvaofboogie" wrote:

Workbooks.OpenText FILENAME:= _
"C:\JDIS_FILES\PURGRPT_" & "*.jdis"


This opens the file in the directory I want to be opened. However my
question is:
If there are say 10 reports with that prefix and suffix in that direcory, is
there a way I can have a macro open the first one, then the next one, then
the next one etc. On down the line until the last one then stop?

Does that make sense?



All times are GMT +1. The time now is 01:30 AM.

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