MysticRyuujin has asked for the wisdom of the Perl Monks concerning the following question:
I'm playing with replacing Japanese text with English text in Word documents using Perl. One of the things I want to do is highlight the text that I replace but I can't seem to get highlighting to work. I think the macro is: Selection.Range.HighlightColorIndex = wdYellow
This is the code I'm working with right now and it will successfully replace Japanese text in the word document but highlighting is eluding me...
use strict; use warnings; use utf8; use Win32::OLE; use Win32::OLE qw(CP_UTF8); use Win32::OLE::Const 'Microsoft Word'; Win32::OLE->Option(CP => CP_UTF8); my $word = Win32::OLE->new('Word.Application'); $word->{Visible} = 0; my $document=$word->Documents->Open('c:/perl/scripts/test.doc'); $word->Selection->HomeKey(wdStory); $word->Selection->Find->{'Text'}='すごい'; $word->Selection->Find->Replacement->{'Text'}='Awesome'; $word->Selection->Find->Execute({Replace=>wdReplaceAll}); $word->Selection->HighlightColorIndex(wdYellow); # THIS I DONT KNOW $word->ActiveDocument->Close ; $word->Quit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to Highlight with OLE
by dasgar (Priest) on Apr 04, 2014 at 17:59 UTC | |
|
Re: How to Highlight with OLE
by Anonymous Monk on Apr 04, 2014 at 01:29 UTC | |
by MysticRyuujin (Novice) on Apr 04, 2014 at 01:40 UTC | |
by Anonymous Monk on Apr 04, 2014 at 01:48 UTC | |
by Anonymous Monk on Apr 04, 2014 at 06:41 UTC |