Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

WIN32::OLE MS Word Replace

by gibsonca (Beadle)
on Oct 15, 2009 at 15:29 UTC ( #801372=perlquestion: print w/ replies, xml ) Need Help??
gibsonca has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks!

I can do a simple find and replace, but how do I change the font in the replacement? For example, in the following code segment I want to underline (or bold) just the word 'will', presume it is in a sentence like 'You will go to the store.'.

$selection->{'Find'}->{'Text'} = " will "; $selection->{'Find'}->{'Replacement'}->{'Text'} = "*** will ***"; $selection->{'Find'}->Execute({Replace => wdReplaceOne});

Any help appreciated.

Comment on WIN32::OLE MS Word Replace
Download Code
Re: WIN32::OLE MS Word Replace
by hominid (Curate) on Oct 15, 2009 at 17:54 UTC
    $selection->{'Find'}->{'Replacement'}->{'Font'}->{'Bold'} = 1
    This should do it. You have been told in other posts how to go about finding solutions to MS Word related automation problems. I would also point out the Word Object Model Reference. For this case look at the Replacement object.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://801372]
Approved by wfsp
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (21)
As of 2015-07-02 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (39 votes), past polls