0
我有一個包含大量鏈接工作簿的文件夾。我想將它的主版本存儲在C:\驅動器中。當有人需要使用它時,他們會點擊下面的宏來複制該文件夾,詢問新名稱將被放置在桌面上以供使用。下面的代碼循環但不放在桌面上的文件夾。它只是似乎消失,並沒有複製原來的使用VBA複製和重命名文件夾
希望有人可以幫忙??
Sub Copy_Folder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim strName As String
FromPath = "C:\v4 Master Operations Folder"
ToPath = "C:\Users\Owner\Desktop"
Application.CutCopyMode = False
Reenter:
strName = InputBox(Prompt:="Enter the name of your operation", _
Title:="Operation.", Default:=" ")
If strName = vbNullString Then
MsgBox "Incorrect Entry."
GoTo Reenter
End If
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath & strName, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath & strName
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath & strName
End Sub