Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Style problem with Word/OLE

by poj (Prior)
on Jul 07, 2013 at 20:10 UTC ( #1043010=note: print w/replies, xml ) Need Help??

in reply to Re: Style problem with Word/OLE
in thread Style problem with Word/OLE

I tried numerous ways but the only one I found that preserved the style was to store it on a first pass and re-apply it on a second pass like this.

my $paragraphs = $file->Paragraphs(); my $n = $paragraphs->Count(); my @style=(); # add for my $p (1..$n) { my $paragraph = $paragraphs->Item( $p ); print "paragraph $p\n"; print "before: $paragraph->{Style}->{NameLocal}\n"; $style[$p] = $paragraph->{Style}->{NameLocal}; # add my $text = $paragraph->{Range}->{Text}; $paragraph->{Range}->{Text} = $text; } for my $p (1..$n) { my $paragraph = $paragraphs->Item( $p ); $paragraph->{Style} = $style[$p]; # add print "after: $paragraph->{Style}->{NameLocal}\n"; }

Replies are listed 'Best First'.
Re^3: Style problem with Word/OLE
by IlanB (Initiate) on Jul 08, 2013 at 07:58 UTC
    Thank you so much, Poj.

    Strangely, I tried a similar solution - saving and restoring the style in the same loop - and it didn't work.

    Your solution with two loops works well.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043010]
[erix]: Harakiri with a nuke on the white house, that'd clean up the staff there a bit too ;)
[erix]: (sorry, I'm always a bit violent on fridays)
LanX predicts problems for Erix next time he lines up at an US immigration counter
[erix]: but tuesdays just as bad
[erix]: thanks for the heads-up but that's a line-up studiiously avoided :P
[LanX]: yeah too far for someone who can't even make it to Amsterdam
LanX looking for a good magit tutorial
LanX ... and git in general

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2017-08-18 13:16 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (302 votes). Check out past polls.