FileSearch method in Word 2002 macro fails

M

Misha

Hello!

The following macro (see below) works well in Microsoft
Word 2002 on a Windows XP machine. The same macro fails
to return results (e.g. files found) when taken to an
identical machine, but running Microsoft Word 2002 with
Service Pack 2. No information was found in MSDN
knowledge base. I would appreciate any suggestions on how
to work around this problem.

Thank you!

Misha

------------
VBA MACRO:
------------

Sub Test()

Dim fs As Object

Set fs = Application.FileSearch
With fs
.LookIn = "C:\temp\"
.FileName = "*.*"
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
.Execute
End With

MsgBox "Files Found = " & fs.FoundFiles.Count

End Sub
 
D

Doug Robbins - Word MVP

Hi Misha,

Are you sure that there is a c:\Temp folder on that machine?

I don't have one on my machine and as a result it returns "Files found = 0"

If I replace Temp with a folder that does exist, it returns the number of
files in the folder.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP
 
M

Misha

Hi Doug,

Thank you for your reply. To answer your question, YES,
the directory does exist on this machine. In fact, I had
tried this example on various directories (all exist)
with different .FileName settings (tried different
extentions, as well a particular file name).

From what I see, it appears to be a bug of Microsoft Word
2002 with SP2 installed. I would very much appreciate any
further suggestions. Thank you for your time!

Misha
 

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