The FileSystemObject VBA MoveFolder function moves one or multiple folders from current to destination location.
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 MoveFolder Syntax
fso.MoveFolder( source, destination )
source
Current location of one or multiple folders. You can use wildcards such as *.* to specify more than a single folder matching the pattern, however, only matching part of the last component of the folder path.
destination
The destination location to which one or multiple folders are to be moved.
VBA MoveFolder Examples
Set fso = CreateObject("Scripting.FileSystemObject") 'Move OldFolderName to C:\Dst and rename to NewFolderName fso.MoveFolder "C:\OlderFolderName", C:\Dst\NewFolderName 'Move all OldFolders to C:\Dst. This will keep their names fso.MoveFolder "C:\*\OlderFolderName", C:\Dst\