ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   flexible file search & opening (https://www.excelbanter.com/excel-programming/338278-flexible-file-search-opening.html)

Markus Scheible[_3_]

flexible file search & opening
 
Hi newsgroup,

I'm a little swamped with an excel task - maybe someone could give me some
hints...

I have to open severate files from a folder where there are around 500
files. They are named after the following scheme:

Report 01.02.2005 12.15.xls
Report 01.02.2005 23.59.xls

Now I need to open all files that contain 01.02.2005 in their file name, not
regarding which time they contain. Does someone know how I can open them
flexibly?

TIA and best regards

Markus

Tom Ogilvy

flexible file search & opening
 
Dim bk as workbook, fname as String
sPath = "c:\myfolder\"
fname = dir(sPath & "Report*.xls")
do while fname < ""
if instr(1,fName,"01.02.2005",vbTextCompare) then
set bk = workbooks.Open(fname)
' process the file
bk.Close SaveChanges:=False
end if
fname = dir()
Loop


--
Regards,
Tom Ogilvy



"Markus Scheible" wrote in
message ...
Hi newsgroup,

I'm a little swamped with an excel task - maybe someone could give me some
hints...

I have to open severate files from a folder where there are around 500
files. They are named after the following scheme:

Report 01.02.2005 12.15.xls
Report 01.02.2005 23.59.xls

Now I need to open all files that contain 01.02.2005 in their file name,

not
regarding which time they contain. Does someone know how I can open them
flexibly?

TIA and best regards

Markus




Markus Scheible[_3_]

flexible file search & opening
 
Hi Tom,


it works great - thanks a lot :o)

Best regards


Markus


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

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