Please note that when searching for "*.xls", files with extensions ".xlsm", ".xlsx" also apparently show up as matches. It seems to be a legacy feature of Windows that 8.3 extensions are matches and other characters in the extension beyond character 3 don't matter.
See http://www.networksteve.com/windows/...=16743&Posts=6
A possible workaround could be the 'like' command:
Sub TestEightDotThree()
Dim sFileName As String
Dim sMask As String
sMask = "*.xls"
sFileName = "Abc.xls"
If sFileName Like sMask Then
MsgBox "'" & sFileName & "' is a match for the mask '" & sMask & " '."
Else
MsgBox "'" & sFileName & "' is NOT a match for the mask '" & sMask & " '."
End If
sFileName = "Abc.xlsm"
If sFileName Like sMask Then
MsgBox "'" & sFileName & "' is a match for the mask '" & sMask & " '."
Else
MsgBox "'" & sFileName & "' is NOT a match for the mask '" & sMask & " '."
End If
End Sub
Lewis
Bookmarks