Sign in to follow this  
Followers 0
saywell

Word interaction query [solved]

2 posts in this topic

#1 ·  Posted (edited)

Ok it's not strictly an Autoit question but it relates to using the word com object from my autoit prog.

I need to delete the contents of a word document and replace it with a short message.

I've tried playing with range.text but this doesn't include the tables etc., though it's fine for adding the message

The VBA would be something like

Selection.HomeKey Unit:=wdStory
Selection.Cut

or perhaps

Selection.WholeStory
Selection.Cut

How do i convert this to Autoit?

I'd thought something like

$oWordApp.ActiveDocument.Selection.WholeStory
                 $oWordApp.ActiveDocument.Selection.Cut
                 $oWordApp.ActiveDocument.Range.Text = "Cancelled by user "&@YEAR&@MON&@MDAY&@HOUR&@MIN&@SEC

The range.txt bit works on its own by replacing the old text with the message, but I can't get the same thing to work on the entire document - using wholestory in place of range.text just gives a com error.

Any suggestions, anyone?

Regards,

William

Edited by saywell

Share this post


Link to post
Share on other sites



Solved after more searching around

$oWordApp.ActiveDocument.Range.WholeStory()
$oWordApp.ActiveDocument.Range.Text= "Cancelled by user "

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  
Followers 0