The The FileSystemObject VBA BuildPath function will create a new path by appending a name to a given path.
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 BuildPath Syntax
fso.BuildPath path, appendname
path
A path to which the appendname is to be appended to. This can be an absolute or relative path. This can end but does not need to end with a backslash.
appendname
The name to be appended to the path.
VBA BuildPath Examples
Set fso = CreateObject("Scripting.FileSystemObject") fso.BuildPath "C:\Src", "Hello.txt" 'Result: C:\Src\Hello.txt fso.BuildPath "C:\Src\", "Hello.txt" 'Result: C:\Src\Hello.txt fso.BuildPath "..", "Hello.txt" 'Result: ..Hello.txt