Jump to content

Word UDF changes _Word_ functions


Jury
 Share

Go to solution Solved by water,

Recommended Posts

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

Link to comment
Share on other sites

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")
Link to comment
Share on other sites

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 by Jury
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 by Jury
Link to comment
Share on other sites

$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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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.



Link to comment
Share on other sites

  • Solution

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 by Jury
Link to comment
Share on other sites

So the Macro problem could be solved?

What's your problem with _Word_DocFindReplace?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Never used it myself before, but could you try:

$oWord.WordBasic.RemoveHeader
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Glad I could solve your problems :)

See you.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...