Jump to content

Word UDF functionality


Recommended Posts

Tucked away in the examples of the word udf are some interesting feature like:

$sText = $oWordApp.Activedocument.Range.Text for getting text

and

$oDoc.Range.insertAfter for entering text

However, I can't find anything in the help files to explain their syntax.

For example, the first example seems only to get the first line of text - how do I get ALL the text? Presumably something to do with 'range'?

I'd be grateful if anyone could point me towards a source of info on what similar functionality might be tucked away with these examples, and some details on how to use them. Do they, perhaps, use syntax from another language?

Thanks,

William

Edited by saywell
Link to comment
Share on other sites

OK so this is Visual Basic for Applications - VBA - as used in Word etc macros, I think.

Lots of documentation on the web.

BUT I need help with the syntax for calling these from Autoit

For example, I can use $oDoc.Range.insertAfter to insert at end of text or

$0Doc.Selection.EndKey to put cursor at end of line.

However, if I try $oDoc.Selection.EndKey Unit:=wdStory to put cursor at the end of the document [as per <ctrl>-End] I get an error due to the space.

So my question is, how do I get Autoit to implement commands with an argument separated by the space?

Regards,

William

Edited by saywell
Link to comment
Share on other sites

However, if I try $oDoc.Selection.EndKey Unit:=wdStory to put cursor at the end of the document [as per <ctrl>-End] I get an error due to the space.

Everything after the space are parameters to the method. So the above statement should read in AutoIt:

$wdStory = 6
$oDoc.Selection.EndKey($wdStory)

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

Everything after the space are parameters to the method. So the above statement should read in AutoIt:

$wdStory = 6
$oDoc.Selection.EndKey($wdStory)

Many thanks. That's the syntax sorted, but where did the $wdStory = 6 come from? Specifically, the value 6?

Found it - 6 is the value for end of text!

William

Edited by saywell
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...