saywell Posted January 5, 2012 Share Posted January 5, 2012 (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 January 6, 2012 by saywell Link to comment Share on other sites More sharing options...
saywell Posted January 6, 2012 Author Share Posted January 6, 2012 Solved after more searching around $oWordApp.ActiveDocument.Range.WholeStory() $oWordApp.ActiveDocument.Range.Text= "Cancelled by user " Link to comment Share on other sites More sharing options...
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