ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Excel files in a folder (https://www.excelbanter.com/excel-programming/274854-re-open-excel-files-folder.html)

Tom Ogilvy

Open Excel files in a folder
 
Perhaps the FileSearch object. This is basically the code in the help file
for the filesearch object. With Application.FileSearch .NewSearch
.LookIn = "C:\My Documents"
.SearchSubFolders = False
.FileName = ".xls"
' .MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
' MsgBox .FoundFiles(i) set wkbk =
workbooks.Open(.foundfiles(i)) ' work on the workbook
wkbk.close Savechanges:=False ' or true
Next i
Else
MsgBox "There were no files found."
End If
End With-- Regards,Tom Ogilvy"John Acocella" wrote
in message ...
I want to retrieve the file names of excel files in a
specific directory, retrieveing them one at a time through
a looping routine. Is there any way to do this in Excel
besides using the DIR function? I thought I read
something in the Microsoft knowledge base, but I can't
find it. Thanks.





All times are GMT +1. The time now is 08:42 AM.

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