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 Destination = "False" Or destinationfile = "" Then Exit Sub
sourcefile = ThisWorkbook.Path & "\" & sourcefile
destinationfile = ThisWorkbook.Path & "\" & destinationfile
If fso.FileExists(sourcefile) Then
fso.CopyFile sourcefile, destinationfile, True
MsgBox "复制成功!"
Else
MsgBox "文件" & sourcefile & "不存在!"
End If
Set fso = Nothing
End Sub
VBA代码,复制文件
最新推荐文章于 2024-06-06 08:32:00 发布