Jump to content
Sign in to follow this  
Jury

Word UDF changes _Word_ functions

Recommended Posts

Jury

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

Share this post


Link to post
Share on other sites
Jury

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")

Share this post


Link to post
Share on other sites
Jury

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

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jury

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

Share this post


Link to post
Share on other sites
water

$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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jury

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.



Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jury

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

Share this post


Link to post
Share on other sites
water

So the Macro problem could be solved?

What's your problem with _Word_DocFindReplace?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jury

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?

Share this post


Link to post
Share on other sites
water

Never used it myself before, but could you try:

$oWord.WordBasic.RemoveHeader
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jury

Great! works a treat - I should've given that a try.

Thanks (until next time I'm afraid)

jury

Share this post


Link to post
Share on other sites
water

Glad I could solve your problems :)

See you.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×