MJaskilka has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Loop through Word Sections?
by ww (Archbishop) on Sep 30, 2010 at 22:54 UTC
    Here's some help, albeit not the kind you asked for.

    The input page for new nodes has boldfaced directions for markup. As a newcomer, you are also required to preview the post.

    Your post suggests you didn't pay any attention to the ill-formatted contents as seen in the preview, and didn't read the instructions.

    Hence, my suggestion: read On asking for help, How do I post a question effectively?, Markup in the Monastery and Writeup Formatting Tips and heed their content. (Hint: one of them will tell you that "not working for me" is not an adequate description of the failure; some of the others will explain how to use our (html-like) markup to make your posts readable.

    Bottom line: the Monastery welcomes newcomers; is a great place to learn more about Perl (and life and why the sky is blue, if you're curious about those) but we do have some really minimal suggestions for how best to access the help given so freely, here.

      Sorry! The preview looked good.
Re: Loop through Word Sections?
by hominid (Priest) on Oct 01, 2010 at 14:15 UTC
    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.
      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? }