Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Loop through Word Sections?

by hominid (Priest)
on Oct 01, 2010 at 14:15 UTC ( [id://862972]=note: print w/replies, xml ) Need Help??


in reply to Loop through Word Sections?

You can loop through the Sections object like this:
... my $sections = $doc->Sections->Count(); for(1..$sections) { $doc->Sections($_)->Headers(1)->Range->InsertAfter("New Header + Text"); } ..
Check the Word Object Model Reference for more information.

Replies are listed 'Best First'.
Re^2: Loop through Word Sections?
by Anonymous Monk on Oct 04, 2010 at 18:32 UTC
    Thank you! I'm close. However, I'm having trouble translating a word marco command into Perl to goto the next section: after I get the count of sections, I do: for ($i=1; $i<=$sections; $i++){ #In Word, it does this next comment line, which I'm not #translating correctly and which sometimes gives the #blue screen of death... #Selection.GoTo what:=wdGoToSection, #which:=wdGoToFirst, Count:=1, Name:="" $doc->ActiveWindow->Selection->Goto ("wdGotoSection", "wdGoToNext", 1, ); #do more stuff...how in the world does above line Xlate? }

      OK, let's try formatting again... Thank you! However, I'm having trouble translating a word macro command into Perl to goto thte next section: After I get the count of sections I do:

      for ($i=1; $i<=$sections; $i++){ #In Word, it does this next comment line, which I'm not #translating c +orrectly and which sometimes gives the #blue screen of death... #Selection.GoTo what:=wdGoToSection, which:=wdGoToFirst, #Count:=1, Name:="" $doc->ActiveWindow->Selection->Goto ("wdGotoSection", "wdGoToNext", 1, + ); #do more stuff...how in the world does above line Xlate? }

        PS, the 'more stuff' is:

        $word_app->Selection->WholeStory; $word_app->Selection->Fields->Update;

        Above works on section 1 of the document only...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://862972]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-24 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found