D T
D T

Reputation: 3746

Copy Open Excel File

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?

Upvotes: 1

Views: 2205

Answers (1)

omegastripes
omegastripes

Reputation: 12612

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

Upvotes: 2

Related Questions