R
RosH
Hi friends,
Given below is a part of my macro. The method Execute in FileSearch
class does not find email file (*.eml) or shortcut files (*.lnk). It
would not be finding other types of files also, but these two are the
ones which i tested failed. Other files like *.doc, *.xls are working
for the FileSearch. Please help.
Set fs = Application.FileSearch
With fs
.LookIn = sLookin
sFileTypeChoice = InputBox("What files are to be searched? Ex.
'doc' for word files", "File Type Choice")
If sFileTypeChoice = "" Then .Filename = "*.*" Else .Filename =
"*." & sFileTypeChoice
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Range("B" & (i + 2)).Select
Range("B" & (i + 2)).Hyperlinks.Add Anchor:=Selection,
Address:=.FoundFiles(i), TextToDisplay:=.FoundFiles(i)
Selection.Replace What:=sLookin & "\", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:= _
False, SearchFormat:=False, ReplaceFormat:=False
Next i
Range("A1").Value = "Files Found: " & .FoundFiles.Count & "
Location: " & sLookin
Else
MsgBox "There were no files found."
Exit Sub
End If
End With
Given below is a part of my macro. The method Execute in FileSearch
class does not find email file (*.eml) or shortcut files (*.lnk). It
would not be finding other types of files also, but these two are the
ones which i tested failed. Other files like *.doc, *.xls are working
for the FileSearch. Please help.
Set fs = Application.FileSearch
With fs
.LookIn = sLookin
sFileTypeChoice = InputBox("What files are to be searched? Ex.
'doc' for word files", "File Type Choice")
If sFileTypeChoice = "" Then .Filename = "*.*" Else .Filename =
"*." & sFileTypeChoice
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Range("B" & (i + 2)).Select
Range("B" & (i + 2)).Hyperlinks.Add Anchor:=Selection,
Address:=.FoundFiles(i), TextToDisplay:=.FoundFiles(i)
Selection.Replace What:=sLookin & "\", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:= _
False, SearchFormat:=False, ReplaceFormat:=False
Next i
Range("A1").Value = "Files Found: " & .FoundFiles.Count & "
Location: " & sLookin
Else
MsgBox "There were no files found."
Exit Sub
End If
End With