Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How do I apply formatting to a particular word in a docx file using Win32::Ole in Perl?

by NetWallah (Canon)
on Sep 23, 2010 at 04:56 UTC ( [id://861444]=note: print w/replies, xml ) Need Help??


in reply to How do I apply formatting to a particular word in a docx file using Win32::Ole in Perl?

You need to use the Range.Words Property to scan the words in the $paragraph->{Range}.

Something like this (Untested, uncompiled):

for my $w ($paragraph->{Range}->Words()){ next unless $w->Text() =~/perl/i; $w->Font->{Bold} = 1; }

     Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

  • Comment on Re: How do I apply formatting to a particular word in a docx file using Win32::Ole in Perl?
  • Download Code

Replies are listed 'Best First'.
Re^2: How do I apply formatting to a particular word in a docx file using Win32::Ole in Perl?
by ZJ.Mike.2009 (Scribe) on Sep 23, 2010 at 06:10 UTC
    @NetWallah, thanks for the guidance. But perl throws me an error suggesting that $w->Text returns an uninitialized value. I've used the following lines of code to check for the keys of the $w hashref:
    my @keys = keys %{$w}; print @keys,"\n";
    And I get the following hash keys: Count First Last Application Creator Parent

    It seems I can only use something like $w->First->Text. But I'm stuck there :(

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://861444]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found