Sub 复制文件夹_Fso()
Dim fso As New Scripting.FileSystemObject
Dim sourcefile As String
Dim destinationfile As String
sourcefile = Application.InputBox(prompt:="请输入需要复制的文件夹名称:" & _
vbCrLf & "(可使用通配符):", Title:="输入文件夹", Type:=2)
destinationfile = Application.InputBox(prompt:="请输入目标文件夹名称:", _
Title:="目标文件夹", Type:=2)
If sourcefile = "False" Or sourcefile = "" Then Exit Sub
If destinationfile = "False" Or destinationfile = "" Then Exit Sub
sourcefile = ThisWorkbook.Path & "\" & sourcefile
destinationfile = ThisWorkbook.Path & "\" & destinationfile
If fso.FolderExists(sourcefile) Then
fso.CopyFolder sourcefile, Destination, True
MsgBox "文件夹复制成功!"
Else
MsgBox "文件夹" & sourcefile & "不存在!"
End If
Set fso = Nothing
End Sub
01-11
11-01