The FileSystemObject VBA GetBaseName function returns the last component of a given path without a file extension. This function applies both to files and folders.
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 GetBaseName Syntax
fso.GetBaseName path
path
The file or folder path which base component you want to extract.
VBA GettBaseName Examples
Set fso = CreateObject("Scripting.FileSystemObject") fso.GetBaseName "C:\Src\Hello.txt" 'Result: Hello fso.GetBaseName "C:\Src\Hello\" 'Result: Hello