I wanna use vba macro to copy or create folder, then I used the FileSystem function. I could run this program for the entire morning, but then suddenly got error saying path not found. I have checked all my path is correct. How should I fix it?

Sub CreateMissingFolders(DestinationFolder As String, FolderNames As Variant)
    Dim FileSystem As Object
    Dim FolderName As Variant
    Set FileSystem = CreateObject("Scripting.FileSystemObject")
    For Each FolderName In FolderNames
        If Not FolderExists(DestinationFolder & "" & FolderName) Then
            FileSystem.CreateFolder DestinationFolder & "" & FolderName
        End If
    Next FolderName
End Sub


Did your pass became too long ? In my memory the max length for a path is about ~250 char

There’s some invalid char in your path ?

Khám phá các thẻ bài đăng