fred_beaucamp Posted April 18, 2018 Posted April 18, 2018 Good afternoon the purpose is the following : I want to open a Word file, run a macro ans save the result as a .docx file. I don't succeed in saving the document with a .docx extension : $word = ObjCreate("Word.Application") $word.visible = True Local $sDocument = "C:\Bazar\isa2docx\AGCMFR.doc" $word.Documents.open($sDocument) $word.Run("PaysageUnix66bis") $word.ActiveDocument.SaveAs("C:\Bazar\isa2docx\AGCMFR.docx") $word.Application.Quit the error is $word.ActiveDocument^ERROR Error the requested action with this object as failed I'm on a win10 computer wth a x64 processor with Microsoft Office 2016 Please Help me. thanks
Subz Posted April 18, 2018 Posted April 18, 2018 Can you try: #include <Word.au3> Local $sDocument = "C:\Bazar\isa2docx\AGCMFR.doc" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($sDocument) $oWord.Run("PaysageUnix66bis") _Word_DocSaveAs($oDoc, "C:\Bazar\isa2docx\AGCMFR.docx", $WdFormatDocumentDefault) _Word_DocClose($oDoc) _Word_Quit($oWord)
water Posted April 18, 2018 Posted April 18, 2018 BTW: It is always a good idea to do some error checking after calling a function. So you always know where the error arises. If not AutoIt might crash a few statements later and you start to debug at the wrong place My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
fred_beaucamp Posted April 24, 2018 Author Posted April 24, 2018 Hi ! Thanks Subz and water for your answers! The code who works is the following : #include <Word.au3> Local $sDocument = "C:\Bazar\isa2docx\AGCMFR.doc" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord,$sDocument) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur ouverture fichier") $oWord.Run("PaysageUnix66bis") _Word_DocSaveAs($oDoc, "C:\Bazar\isa2docx\AGCMFR.docx", $WdFormatDocumentDefault) _Word_DocClose($oDoc) _Word_Quit($oWord) We can close this topic !
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now