Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookin property of the FileSearch object [email protected] New Users to Excel 0 December 5th 06 09:37 PM
FILESEARCH OBJECT jason Excel Programming 1 December 29th 04 01:19 PM
csv for filetype property of filesearch object smokiibear Excel Programming 3 December 14th 04 04:59 PM
Cannot assign value to Filesearch.Lookin QQExcel Excel Programming 3 August 5th 04 04:20 PM
Multiple text criteria with FileSearch object? Ed[_9_] Excel Programming 1 September 23rd 03 09:26 PM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"