I'm able to restart my script or close the file and then reopen it to use ComObjActive but I want to know if it's possible for me to avoid doing either. Essentially, how do I release the COM object (file/application) such that ComObjActive can be used immediately after? E.g. I want to be able to do the following:
Code: Select all
F1::
Word_App := ComObjCreate("Word.Application")
Word_File := Word_App.Documents.Open("TestFile.docx")
Word_App.Visible := 1
Word_App.Activate
/*
Do Stuff
*/
Word_File.SaveAs(A_Desktop "\Test.docx")
;The Word File remains open for the user. How do I release the COM Object here,
;without using "Word_App.Quit", which closes the application and the open file?
Return
F2::
Word_Application := ComObjActive("Word.Application")
;This doesn't work (it doesn't select the word file that was opened with ComObjCreate)
PDF_FullPath := StrReplace(Word_Application.ActiveDocument.FullName, ".docx", ".pdf")
ActiveDocument.SaveAs2(PDF_FullPath, 17)
Return