Jury Posted December 27, 2013 Posted December 27, 2013 Loving AutoIt v3.3.10.0 but I don't understand thinking as to why the old Word UDF functions such as _WordMacroRun and _WordDocPropertySet no longer exist. Can't these things be done with new versions of Word or have these yet to be added or is there a better method of doing these functions (if so are there any examples somewhere?) jury
Jury Posted December 27, 2013 Author Posted December 27, 2013 Oh! playing around with Waters example here: '?do=embed' frameborder='0' data-embedContent>> I've done below which changes the property Title to cat - now for figuring out how to do _WordMacroRun #include <Word.au3> #include <MsgBoxConstants.au3> $processing = @MyDocumentsDir & '\AutoIt_code\getter\processing\' $out = @MyDocumentsDir & '\AutoIt_code\getter\processing\out\' Global $oWord = _Word_Create() $sDocument = $processing & "\test.doc" $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, True) $oDoc.BuiltInDocumentProperties('Title').value = 'cat' _Word_DocSaveAs($oDoc, $processing & "\test_out.doc")
Jury Posted December 27, 2013 Author Posted December 27, 2013 (edited) perhaps adding something like these below - Macro17 is the pre-recorded Word macro (thes don't work though) any ideas? $oDoc.DoCmd.RunMacro("Macro17") or $oDoc.RunMacro ("Macro17") Edited December 27, 2013 by Jury
water Posted December 29, 2013 Posted December 29, 2013 Loving AutoIt v3.3.10.0 but I don't understand thinking as to why the old Word UDF functions such as _WordMacroRun and _WordDocPropertySet no longer exist. Can't these things be done with new versions of Word or have these yet to be added or is there a better method of doing these functions (if so are there any examples somewhere?) jury This functions have been removed because they were only wrappers for a one line function. This things can still be done with new versions of Word. Maybe I'm going to create a wiki section to answer this kind of questions and add some examples ... 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
Jury Posted December 30, 2013 Author Posted December 30, 2013 (edited) Thanks Water I'm now trying to write a script to run this Word macro using the Excel With..EndWith example on help item 'COM Extensions to AutoIt' - I can't see any other way to do this using with _Word_DocFindReplace. Please tell me if I'm going in the correct direction. Sub ex_header() WordBasic.RemoveHeader End Sub Edited December 30, 2013 by Jury
water Posted December 30, 2013 Posted December 30, 2013 $oAppl.Run("ex_header") should do what you want. $oAppl is the Word application object as returned by _Word_Create. 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
Jury Posted December 30, 2013 Author Posted December 30, 2013 So if I do this Global $oWord = _Word_Create() $sDocument = $processing & "\2331.rtf" $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, False) $oAppl = ObjCreate("Word.Application") $oDoc.$oAppl.Run("ex_header") I get: Microsoft Visual Basic Run-time error 'S09': The RemoveHeader command is not available because a document window is not active.
Solution water Posted December 30, 2013 Solution Posted December 30, 2013 Should be:Global $oWord = _Word_Create() $sDocument = $processing & "\2331.rtf" $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, False) $oWord.Run("ex_header") 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
Jury Posted December 30, 2013 Author Posted December 30, 2013 (edited) Oh! now I see I can't get it into my head that these object names are assigned rather than being pre-defined in the COM object (if that makes any sense) and of course you did tell me the " $oAppl is the Word application object as returned by _Word_Create". This opens up all sorts of fun possibilities regarding macros - and I now see why you didn't include this as a functions in the UDF - once again thanks ever so much. jury Edited December 30, 2013 by Jury
water Posted December 30, 2013 Posted December 30, 2013 So the Macro problem could be solved? What's your problem with _Word_DocFindReplace? 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
Jury Posted December 30, 2013 Author Posted December 30, 2013 Oh I see I've got two topics here - no problems now with _Word_DocFindReplace it works perfectly so everything is fine now but as for the Word Macro can't I just run that macro instruction (WordBasic.RemoveHeader) without having it in a macro I've created in Word?
water Posted December 30, 2013 Posted December 30, 2013 (edited) Never used it myself before, but could you try: $oWord.WordBasic.RemoveHeader Edited December 30, 2013 by water 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
Jury Posted December 30, 2013 Author Posted December 30, 2013 Great! works a treat - I should've given that a try. Thanks (until next time I'm afraid) jury
water Posted December 30, 2013 Posted December 30, 2013 Glad I could solve your problems See you. 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
water Posted January 1, 2014 Posted January 1, 2014 I have added a section to the AutoIt wiki about the Word UDF describing the script breaking changes and how to mimic old functionality. Ii's still work in progress but if something is missing, please let me know. 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
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