The FileSystemObject VBA GetExtensionName function returns a string with the file extension of a given file path. Will return a null string (vbNullString) if no extension is found or the path does not match a file.
VBA FileSystemObject Methods
- BuildPath
- CopyFile
- CopyFolder
- CreateFolder
- CreateTextFile
- DeleteFile
- DeleteFolder
- DriveExists
- FileExists
- FolderExists
- GetAbsolutePathName
- GetBaseName
- GetDrive
- GetDriveName
- GetExtensionName
- GetFile
- GetFileName
- GetFolder
- GetParentFolderName
- GetSpecialFolder
- GetTempName
- MoveFile
- MoveFolder
- OpenTextFile
VBA GetExtensionName Syntax
fso.GetExtensionName( path )
path
The path for which the file extension is supposed to be specified.
VBA GetExtensionName Examples
Set fso = CreateObject("Scripting.FileSystemObject") fso.GetExtensionName ("C:\Src\Hello.txt") 'Result: "txt" fso.GetExtensionName ("C:\Src") 'Result: "" (null string)