ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with Filesearch in Excel 2007 (https://www.excelbanter.com/excel-programming/411870-problem-filesearch-excel-2007-a.html)

Raj[_2_]

Problem with Filesearch in Excel 2007
 
Hi,

I was using the following code in Excel 2003 to look in the specified
folder, and open files with ".xls" extension, and then do something
with the file.

With Application.FileSearch
.NewSearch
.LookIn = "D:\rspData"
.Filename = "*.xls"
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
varname = .FoundFiles(i)
Workbooks.Open Filename:=varname

In Excel 2007, FileSearch is giving an error. How could I achieve what
I want either by changing the code above or using some other code?

Thanks in advance for all the help.

Regards,
Raj

Norman Jones[_2_]

Problem with Filesearch in Excel 2007
 
Hi Raj.

Many people complained of problematic
performance with FileSearch and Excel
decided to drop it from Excel 2007.

You can use Dir or the FileSystemObject.

For examples of usage, see help or Google this
NG. See also Ron de Bruin's example usage at:

http://www.rondebruin.nl/copy3.htm


If you experience problems adapting your
code to these approaches, post back.




---
Regards.
Norman


"Raj" wrote in message
...
Hi,

I was using the following code in Excel 2003 to look in the specified
folder, and open files with ".xls" extension, and then do something
with the file.

With Application.FileSearch
.NewSearch
.LookIn = "D:\rspData"
.Filename = "*.xls"
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
varname = .FoundFiles(i)
Workbooks.Open Filename:=varname

In Excel 2007, FileSearch is giving an error. How could I achieve what
I want either by changing the code above or using some other code?

Thanks in advance for all the help.

Regards,
Raj




All times are GMT +1. The time now is 10:28 AM.

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