【VBA】Move folder

You can move folder!

PR

VBA Code

As an example, move the folder.

folder
folder
Option Explicit

Sub sampleProc()
    
    Dim fso As Object
    Dim folderFullPath As String
    Dim newFolderFullPath As String
    
    'Set "Folder path you want to move"
    folderFullPath = "C:\Users\user\Desktop\hogehoge"
    
    'Set "Folder path"
    newFolderFullPath = "C:\Users\user\Desktop\folder_001\"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    'Move Folder
    Call fso.MoveFolder(Source:=folderFullPath, _
                        Destination:=newFolderFullPath)
    
    Set fso = Nothing
    
End Sub

Set “Folder path you want to move”(Line 10).

Set “Folder path”(Line 13).

Move Folder(Line 18).

PR

Result

You moved folder!

Result
Result
PR

FYI

For more information about following, see the following official online manual:

MoveFolder method” of “FileSystemObject”

タイトルとURLをコピーしました