Application.FileSearch problem

R

Roy Lasris

I have created the below routine:
=============
With Application.FileSearch
.NewSearch
.filename = "*.doc"
.LookIn = "c:\my documents"
.Execute SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending
Counter = .FoundFiles.count
End With
==============
It works perfectly on 3 out my 4 installations. It will not work on my fourth
(WindowsXP pro/Word2003). It always returns "0" as the count of files, when
there are hundreds of files. What is wrong -- the macro or the computer?
 
J

JB

Roy said:
I have created the below routine:
=============
With Application.FileSearch
.NewSearch
.filename = "*.doc"
.LookIn = "c:\my documents"
.Execute SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending
Counter = .FoundFiles.count
End With
==============
It works perfectly on 3 out my 4 installations. It will not work on my fourth
(WindowsXP pro/Word2003). It always returns "0" as the count of files, when
there are hundreds of files. What is wrong -- the macro or the computer?

The Macro Looks ok! I tested it on my XPPro/Office2003ProSP1

How did you declare Counter?
Are you calling this macro as a seperate sub and if so how are you
passing the variable? as Public or ByRef?

J
 
J

JB

Roy said:
I have created the below routine:
=============
With Application.FileSearch
.NewSearch
.filename = "*.doc"
.LookIn = "c:\my documents"
.Execute SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending
Counter = .FoundFiles.count
End With
==============
It works perfectly on 3 out my 4 installations. It will not work on my fourth
(WindowsXP pro/Word2003). It always returns "0" as the count of files, when
there are hundreds of files. What is wrong -- the macro or the computer?

Forgot to say that you might be better looking at $Dir to do this
instead of Application.Filesearch. I've heard a lot of people recently
complaining about not getting it to work as expected and the code they
have looks OK.

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top