Copy Open Excel File

2020-04-18 09:43发布

I want copy target macro to new location:

Dim strDes As String
strDes = "D:\" & ActiveWorkbook.Name
FileCopy ActiveWorkbook.FullName, strDes

it occur error

permission denied

How can copy an Excel file that is open?

标签: excel vba
1条回答
做个烂人
2楼-- · 2020-04-18 09:59

You may copy the opened file using Scripting.FileSystemObject

Sub test()

    src = ThisWorkbook.FullName
    dest = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\"
    CreateObject("Scripting.FileSystemObject").CopyFile src, dest

End Sub
查看更多
登录 后发表回答