Answer the question
In order to leave comments, you need to log in
How to copy open vba file with script?
Damn guys, you can talk as much as you like, Google to help read the documentation. but alas, I found everything, I tried all the variations
in this case, it gives an error 424
for example, I inserted the path of the pace, I understand that it is most likely incorrectly indicated, but I tested for an error exactly the same
(ThisWorkbook.Path & "\doc.docm")
But the actual code itself
Sub WorkBook_open()
Set fso = CreateObject("Scripting.FileSystemObject")
Set File = fso.GetFile(ThisWorkbook.Path & "\doc.docm")
Set File = fso.Copy("%Temp%\d6c.docm")
End Sub
Answer the question
In order to leave comments, you need to log in
What for was it to delete the previous version of the question?
Okay, I'll repeat. The FileSystemObject does not have a Copy method, the Folder and File objects do. Therefore,
Set File = fso.GetFile(ThisWorkbook.Path & "\doc.docm")
Set File = fso File.Copy("%Temp%\d6c.docm")
PS. What is an "open file", where, by whom and in general why is it open - I did not understand.
I do this with a VBA macro in Excel
Dim Wd As Object, Wapp As Object
Let Shablon = ThisWorkbook.Path + "\Шаблоны аддонов\" + WorldShablonFileName
Let ИмяФайла = ThisWorkbook.Path + "\" + "Имя файла.docx"
Rem -= копируем шаблон по новому пути =-
Set Wapp = CreateObject("Word.Application"): AppWord.Visible = False
Set Wd = Wapp.Documents.Open(Shablon, ReadOnly:=True)
Wd.SaveAs Filename:=ИмяФайла, FileFormat:=wdFormatXMLDocument
Wd.Close False: Set Wd = Nothing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question