in reply to Win32 ->Replacement->{Text} more than 255 characters
You could search for and delete the token then insert the new text
poj#!perl use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; my $word = Win32::OLE->new('Word.Application', 'Quit') or die; $word->{Visible} = 1; $word->{DisplayAlerts} = 0; my $doc = $word->Documents->Open({FileName => "c:/temp/Word.doc"}); my $sel = $word->Selection; $sel->Find->{Forward} = 1; $sel->Find->{MatchWholeWord} = 1; for my $n (1..2){ $sel->Find->{Text} = '##TOKEN'.$n.'##'; $sel->Find->Execute; $sel->Delete; $sel->InsertAfter("($n) This is line 1 of some new text that is more + than 255 characters. This is line 2 of some new text that is more than 255 characters. This is line 3 of some new text that is more than 255 characters. This is line 4 of some new text that is more than 255 characters. This is line 5 of some new text that is more than 255 characters. This is line 6 of some new text that is more than 255 characters. This is line 7 of some new text that is more than 255 characters. This is line 8 of some new text that is more than 255 characters."); $sel->MoveDown({Count=>1}); }; $doc->SaveAs({FileName => 'c:/temp/Word1.doc'}); $doc->Close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32 ->Replacement->{Text} more than 255 characters
by 3dbc (Monk) on Jan 25, 2017 at 16:48 UTC |