FileSearch

Z

zkid

I use the following code to fetch a list of files from a particular folder
(it actually loads an array, but I've simplied the code for this purpose):

Dim iCount as integer, i as integer

With Application.FileSearch
.NewSearch
.LookIn = [the folder path]
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles

If .Execute() Then
iCount = .FoundFiles.Count
If iCount = 0 Then
Exit Sub
End If
For i = 1 To iCount
Msgbox .FoundFiles(i)
Next i
Else
Exit Sub
End If
End With

This code works flawlessly in versions lower than Word 2003. However, for
some bizarre reason, if I create a new file in the "lookin" folder, 2003
doesn't always see it for at least 15 minutes. Has anyone else had this
problem?

Thanks.
 
Z

zkid

Thanks, Edward.

I did try .RefreshScops, and it didn't make any difference. I did discover,
however, that exiting Word and coming back in refreshes the list. However,
of course, this isn't an option.

Again, this is only occurring in Word 2003. Thanks for trying.

zkid

Edward Thrashcort said:
I think you may have to use the .RefreshScopes method as well?

Eddie
*From:* "zkid <[email protected]>
*Date:* Tue, 22 Nov 2005 13:27:03 -0800

I use the following code to fetch a list of files from a particular
folder (it actually loads an array, but I've simplied the code for this
purpose):

Dim iCount as integer, i as integer

With Application.FileSearch
.NewSearch
.LookIn = [the folder path]
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles

If .Execute() Then
iCount = .FoundFiles.Count
If iCount = 0 Then
Exit Sub
End If
For i = 1 To iCount
Msgbox .FoundFiles(i)
Next i
Else
Exit Sub
End If
End With

This code works flawlessly in versions lower than Word 2003. However,
for some bizarre reason, if I create a new file in the "lookin" folder,
2003 doesn't always see it for at least 15 minutes. Has anyone else had
this problem?

Thanks.
 
E

Edward Thrashcort

Maybe you could try a bit of lateral "trickery"? If you issued a "dir()"
command prior to doing the file search, then maybe this would refresh the
current scope?

Maybe there are other file system commands that would do the job.
I'd also checkout ALL the methods listed in Word2003 "FileSearch" online
help. Maybe MS has added something to solve this problem? I don't have
2003 on this machine so I can't check it out.

Eddie
*From:* "zkid <[email protected]>
*Date:* Wed, 23 Nov 2005 14:43:02 -0800

Thanks, Edward.

I did try .RefreshScops, and it didn't make any difference. I did
discover, however, that exiting Word and coming back in refreshes the
list. However, of course, this isn't an option.

Again, this is only occurring in Word 2003. Thanks for trying.

zkid

Edward Thrashcort said:
I think you may have to use the .RefreshScopes method as well?

Eddie
*From:* "zkid <[email protected]>
*Date:* Tue, 22 Nov 2005 13:27:03 -0800

I use the following code to fetch a list of files from a particular
folder (it actually loads an array, but I've simplied the code for
this purpose):

Dim iCount as integer, i as integer

With Application.FileSearch
.NewSearch
.LookIn = [the folder path]
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles

If .Execute() Then
iCount = .FoundFiles.Count
If iCount = 0 Then
Exit Sub
End If
For i = 1 To iCount
Msgbox .FoundFiles(i)
Next i
Else
Exit Sub
End If
End With

This code works flawlessly in versions lower than Word 2003.
However, for some bizarre reason, if I create a new file in the
"lookin" folder, 2003 doesn't always see it for at least 15 minutes.
Has anyone else had this problem?

Thanks.
 
Z

zkid

Thanks, Edward. You gave me a great idea - I'm just going to use the Dir$()
command code instead of FileSearch. It seems to work cleaner.

zkid

Edward Thrashcort said:
Maybe you could try a bit of lateral "trickery"? If you issued a "dir()"
command prior to doing the file search, then maybe this would refresh the
current scope?

Maybe there are other file system commands that would do the job.
I'd also checkout ALL the methods listed in Word2003 "FileSearch" online
help. Maybe MS has added something to solve this problem? I don't have
2003 on this machine so I can't check it out.

Eddie
*From:* "zkid <[email protected]>
*Date:* Wed, 23 Nov 2005 14:43:02 -0800

Thanks, Edward.

I did try .RefreshScops, and it didn't make any difference. I did
discover, however, that exiting Word and coming back in refreshes the
list. However, of course, this isn't an option.

Again, this is only occurring in Word 2003. Thanks for trying.

zkid

Edward Thrashcort said:
I think you may have to use the .RefreshScopes method as well?

Eddie

*From:* "zkid <[email protected]>
*Date:* Tue, 22 Nov 2005 13:27:03 -0800

I use the following code to fetch a list of files from a particular
folder (it actually loads an array, but I've simplied the code for
this purpose):

Dim iCount as integer, i as integer

With Application.FileSearch
.NewSearch
.LookIn = [the folder path]
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles

If .Execute() Then
iCount = .FoundFiles.Count
If iCount = 0 Then
Exit Sub
End If
For i = 1 To iCount
Msgbox .FoundFiles(i)
Next i
Else
Exit Sub
End If
End With

This code works flawlessly in versions lower than Word 2003.
However, for some bizarre reason, if I create a new file in the
"lookin" folder, 2003 doesn't always see it for at least 15 minutes.
Has anyone else had this problem?

Thanks.
 

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