any ideas on an alternative approach

You could search for and delete the token then insert the new text

#!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();
poj

In reply to Re: Win32 ->Replacement->{Text} more than 255 characters by poj
in thread Win32 ->Replacement->{Text} more than 255 characters by 3dbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.