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 :(