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
  • 11,506
  • 5
  • 20
  • 33
D T
  • 3,522
  • 7
  • 45
  • 89

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
  • 12,351
  • 4
  • 45
  • 96