Word - Application.FileSearch.Filename anomaly setting beginning of filename substring
Asked By FUBARinSFO
06-Dec-07 08:45 PM

Hi:
The problem is that I want to find files like "'INV*.DOC", but I'm
also picking up "xxINV*.DOC" files as well.
DOS doesn't have this problem, but Application.FileSearch.Filename
seems to have it.
If I specifiy a wildcard for the file extension, it works OK, but not
if I specify the extension. e.g. "INV*.*" doesn't pick up the
Indexing is turned off. Using Word 2003. I have seen that there are
problems with this function, but I can't believe at Office11 this
problem hasn't been sorted out.
Code example below
Thanks in advance for your help.
-- Roy Zider
Public Sub TestFileSearch()
' 12/3/2007 lsz
' Testing application.filesearch for start of filename problem with
xxinv*.doc
' Test with three files: t1.txt, t2.txt and xxt3.txt
Dim oFS As Object
Dim i As Integer
Set oFS = Application.FileSearch
With oFS
.LookIn = "C:\temp test\filesearch"
.FileName = "t*.*" ' OK - xxt3.txt not found
' .FileName = "t*.txt" ' not OK -- finds xxt3.txt as well
' .FileName = "inv*.doc" ' not OK -- finds xxinv.doc
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
Application.FileSearch.Filename
(1)
Word 2003
(1)
FoundFiles.Count
(1)
TestFileSearch
(1)
XxINV
(1)
OFS
(1)
Zider
(1)
Application.filesearch
(1)
zki replied...
Well, that's not very logical, is it?! Anyway, here are a couple of fixes:
First, instead of Dim oFS As Object, dimension it as Dim oFS As FileSearch.
It won't change how the code works, but it will provide you pop-up content
help.
Second, change the document extension as follows: "Inv*.doc" becomes
It works - can't explain why....
jeff denner replied...
Hi
This post looks exactly what I want but the end part of the following sentence is missing
Second, change the document extension as follows: "Inv*.doc" becomes
can anbody help
Thanks
FileSearch only returns Word docs Word When I use Application.FileSearch, it only returns Word documents: With Application.FileSearch .FileName = strNewFile '6386_P05*.* .LookIn = strGradingDocPath 'C: \ 6386 .SearchSubFolders = True .Execute Any ideas on how to pick up all file types? Running Office 2003. - - Bryan Word VBA Discussions FileSearch (1) MsoFileTypeOfficeFiles (1) MsoFileTypeAllFiles (1) StrGradingDocPath (1) SearchSubFolders (1) StrNewFile (1) HTML
word 2007 to word 2003 Word How can I view word 2007 documents using Word 2003? Word Document Management Discussions PowerPoint 2007 (1) Word 2007 (1) Word 2003 (1) Office (1) Excel
Word 2003 & Word 2007 Word I discovered quick picks in 2007. My question is, is there are similar feature in Word 2003? thanks, - - Word Document Management Discussions Microsoft Word (1) Word 2007 (1) Word 2003 (1) AutoText (1) In Word 2003 there is AutoText
Default Normal.dot hangs Word 2003! Word Word 2003 hangs when opening. Deleting Normal.dot allows Word to open but then the next time Word is opened it will hang again (if I then delete the newly created Normal.dot Word will open one time again. Using the / a switch works every time. FYI, I had