Option Explicit
Sub main()
Dim sFile As String
Dim oFSO As Scripting.FileSystemObject
sFile = "C:\autoexec.bat"
Set oFSO = CreateObject("Scripting.FileSystemObject")
MsgBox oFSO.GetExtensionName(sFile)
Set oFSO = Nothing
MsgBox ExtName(sFile)
End Sub
Private Function ExtName(ByVal sFile As String) As String
Dim nWhere As Long
Debug.Print sFile
nWhere = InStrRev(sFile, "\")
If nWhere > 0 Then
sFile = Mid$(sFile, nWhere + 1)
Debug.Print sFile
End If
nWhere = InStrRev(sFile, ".")
If nWhere > 0 Then
sFile = Mid$(sFile, nWhere + 1)
Debug.Print sFile
ExtName = sFile
End If
End Function