Hello,
I would like to make changes to Word paragraphs using perl by reading the paragraph text, modifying it and writing it back. But even without changing anything, after writing back, the paragraph inherits the style of the subsequent paragraph. Below I demonstrate it with a file that contains 3 paragraphs with styles "Heading 1", "Heading 2" and "Heading 3". After writing back, the styles became "Heading 2" and "Heading 3" and "Normal". Any idea what am I doing wrong?
Thanks, Ilan
my $paragraphs = $file->Paragraphs(); my $n = $paragraphs->Count(); for my $p (1..$n) { my $paragraph = $paragraphs->Item( $p ); print "paragraph $p\n"; print "before: $paragraph->{Style}->{NameLocal}\n"; my $text = $paragraph->{Range}->{Text}; $paragraph->{Range}->{Text} = $text; print "after: $paragraph->{Style}->{NameLocal}\n"; } Output: paragraph 1 before: Heading 1 after: Heading 2 paragraph 2 before: Heading 2 after: Heading 3 paragraph 3 before: Heading 3 after: Normal
In reply to Style problem with Word/OLE by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |