Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
FileSearch Object - Cannot assign to variable
Hi All, Can anyone help me understand why the following code does not work: It bombs on the penultimate line (myFiles = ...) I was hoping to use myFiles to recursively open each file in that collection, and then copy / paste to a master file (new worksheet for each file) to get each separate xls file into a single workbook. BTW, for the avoidance of doubt, every file in the C:\Temp folder *is* an excel file. Thanks, Alan. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Sub GetFiles() With Application.FileSearch .LookIn = "C:\Temp" .FileType = msoFileTypeAllFiles .SearchSubFolders = True .Execute End With myFiles = Application.FileSearch.FoundFiles End Sub +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
FileSearch Object - Cannot assign to variable
Sub GetFiles()
set fs = application.FileSearch with fs .NewSearch .LookIn = "C:\Temp" .FileType = msoFileTypeExcelWorkbooks .SearchSubFolders = True if .Execute 0 then for i = 1 to .foundfiles.count set wkbk = worbooks.open .foundfiles(i) ' wkbk.close Savechanges:=False next End if End With -- Regards, Tom Ogilvy "Alan" wrote in message ... Hi All, Can anyone help me understand why the following code does not work: It bombs on the penultimate line (myFiles = ...) I was hoping to use myFiles to recursively open each file in that collection, and then copy / paste to a master file (new worksheet for each file) to get each separate xls file into a single workbook. BTW, for the avoidance of doubt, every file in the C:\Temp folder *is* an excel file. Thanks, Alan. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Sub GetFiles() With Application.FileSearch .LookIn = "C:\Temp" .FileType = msoFileTypeAllFiles .SearchSubFolders = True .Execute End With myFiles = Application.FileSearch.FoundFiles End Sub +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Lookin property of the FileSearch object | New Users to Excel | |||
FILESEARCH OBJECT | Excel Programming | |||
csv for filetype property of filesearch object | Excel Programming | |||
Cannot assign value to Filesearch.Lookin | Excel Programming | |||
Multiple text criteria with FileSearch object? | Excel Programming |