3dbc has asked for the wisdom of the Perl Monks concerning the following question:
Below is a code snippet, not complete script, but if you know Win32::ole I think it should make sense what my problem is, but please do let me know if you have any questions. I have the error it generates too if that's helpful, i.e. when it's not within the if / else and perl tries to write the scalar which is over 255 chars.my $doc = $Word->Documents->Open($_[0]) || die("Unable to open documen +t ", Win32::OLE->LastError()); # Open document #my $doc = $MSWord->Documents->Open({FileName=>$_[0]}); # Exit nicely if we couldn't open doc return unless $doc; # Content object my $content=$doc->Content; #my $selection = $word->Selection; print "Finding Tokens...\n"; # Find object my $find=$content->Find; $find->ClearFormatting; $find->{Text}="##TOKEN_REPLACE##"; $find->Replacement->ClearFormatting; $find->Replacement->{Text}=$cant_be_more_than_255
Thanks.if (length($service_screens) > 255) { print "These are $service_screens string is over 255 \n\n" +; $find->ClearFormatting; $find->{Text}="##TOKEN_REPLACE##"; $find->Replacement->ClearFormatting; $find->Replacement->{Text}="Service Screens"; #$doc->ActiveWindow->Selection->MoveDown(wdLine,1); #$doc->ActiveWindow->Selection->TypeText("Can't write scal +ar because it's over 255 chars??"); $find->Execute({Replace=>$wd->{wdReplaceAll},Forward=>$wd- +>{True}}); } else { $find->ClearFormatting; $find->{Text}="##TOKEN_REPLACE##"; $find->Replacement->ClearFormatting; $find->Replacement->{Text}=$service_screens; #$doc->ActiveWindow->Selection->MoveDown(wdLine,1); #$doc->ActiveWindow->Selection->TypeText("This line should + be after the Service screen"); $find->Execute({Replace=>$wd->{wdReplaceAll},Forward=>$wd- +>{True}}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32 ->Replacement->{Text} more than 255 characters
by kcott (Archbishop) on Jan 25, 2017 at 07:18 UTC | |
|
Re: Win32 ->Replacement->{Text} more than 255 characters
by poj (Abbot) on Jan 25, 2017 at 10:03 UTC | |
by 3dbc (Monk) on Jan 25, 2017 at 16:48 UTC |