amalakijr Posted June 11, 2014 Share Posted June 11, 2014 Good day, I'm newbie using autoit and trying word manipulation. What I want is to open a word file, remove highlights and header: Below is my start code: #include <Word.au3> #include <MsgBoxConstants.au3> ;~ ; Create application object Global $oWord = _Word_Create() If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open test document read-only Global $oDoc = _Word_DocOpen($oWord, @ScriptDir & "test.doc", Default, Default, True) If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error opening 'test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Hope you may help me how to proceed. Thanks in advance! Regards, Jun Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 11, 2014 Moderators Share Posted June 11, 2014 Hi, amalakijr. I have never used the Word UDF, but am sure someone will wander by to show you how to do what you're asking. In the meantime, here is a script to do it without the UDF: Remove any highlighting: $oWord = ObjCreate("Word.Application") $oWord.Visible = True $oDoc = $oWord.Documents.Open("C:\Users\JeremiaL\Desktop\Test.doc") $oRange = $oDoc.Range $oRange.Find.Highlight = True $oRange.Find.Forward = True While $oRange.Find.Execute If $oRange.HighlightColorIndex <> 0 Then $oRange.HighlightColorIndex = 0 $position = $oRange.End $oRange.Start = $position WEnd amalakijr 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
amalakijr Posted August 5, 2014 Author Share Posted August 5, 2014 Thanks JLogan3o13, I'll test the code and let you know the result. 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