VBA GetBaseName

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 GetBaseName Syntax

1
fso.GetBaseName path

path
The file or folder path which base component you want to extract.

VBA GettBaseName Examples

1
2
3
4
5
Set fso = CreateObject("Scripting.FileSystemObject")
 
fso.GetBaseName "C:\Src\Hello.txt" 'Result: Hello
 
fso.GetBaseName "C:\Src\Hello\" 'Result: Hello