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

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