Jump to content
Sign in to follow this  
amalakijr

Delete word highlight and header

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

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  

×
×
  • Create New...