1

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?

braX
  • 10,905
  • 5
  • 18
  • 32
D T
  • 2,998
  • 7
  • 37
  • 76

1 Answers1

1

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
omegastripes
  • 11,971
  • 4
  • 40
  • 81