in reply to Re: how to replace superscript using Win32::OLE
in thread how to replace superscript using Win32::OLE

I want to replace only the superscript numbers alone, but for me all the numbers are changing.

  • Comment on Re^2: how to replace superscript using Win32::OLE

Replies are listed 'Best First'.
Re^3: how to replace superscript using Win32::OLE
by traveler (Parson) on Mar 09, 2005 at 17:43 UTC
    This seems to work:
    use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Const 'Microsoft Office'; use Constant 'True' => 1; use Constant 'False' => 0; #$Win32::OLE::Warn = 2; # Throw Errors, I'll catch them my $word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit'); my $mydoc = $word->activedocument; my $rng = $mydoc->{range}; $rng->find->clearformatting; $rng->find->replacement->clearformatting; $rng->find->font->{Superscript}= msoTrue; $rng->find->execute({findtext=>"[0-9]", wrap=>wdFindContinue, replacewith=>"<sup>^&</sup>", matchwildcards=>'True', # matchallwordforms => msoFalse, replace=>wdReplaceAll});