• Macro for paragraph on same page

    Author
    Topic
    #461568

    In a long document, I want to run a macro to check every paragraph to make sure that it does not cross over to the next page. If it does, set the paragraph property to “Keep lines together.” How do I check if the paragraph crosses over to the next page?

    Do I have to check the page number of the beginning of the paragraph with the page number of the end of the paragraph? If so, how would I determine the page number? Or, is there an easier way?

    Viewing 0 reply threads
    Author
    Replies
    • #1171602

      Why don’t you select the entire document (Ctrl+A) and tick the “Keep together” check box in the Line and Page Breaks tab of the Format Paragraph dialog? This will have the same effect, without needing any code.

      • #1171617

        Why don’t you select the entire document (Ctrl+A) and tick the “Keep together” check box in the Line and Page Breaks tab of the Format Paragraph dialog? This will have the same effect, without needing any code.

        Well I wasn’t thinking of making every paragraph in the document “keep together” but yes that would work. After doing that, when I turn on the pilcrow button I will see small black square symbols all down the left margin once for every paragraph in the document but I think my users could live with that. Thank you!

        • #1171619

          The problem with making individual paragraphs keep together if they cross a page boundary is that this pushes the text below such paragraphs down the page. This could cause new paragraphs to cross a page boundary, so you would need to repeat the process, and this could cause yet other paragraphs to cross a page boundary, etc. etc. So it’s much more efficient to set ALL paragraphs to keep together.

          • #1171663

            The problem with making individual paragraphs keep together if they cross a page boundary is that this pushes the text below such paragraphs down the page. This could cause new paragraphs to cross a page boundary, so you would need to repeat the process, and this could cause yet other paragraphs to cross a page boundary, etc. etc. So it’s much more efficient to set ALL paragraphs to keep together.

            Another reason for setting all paragraphs with the ‘keep together’ attribute is that, if you edit the document after setting only some of the paragraphs with the ‘keep together’ attribute, that editing could mess up all the work you’ve already done. Personally, I’d manage the ‘keep together’ attribute via Style formatting.

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

            • #1172170

              Another reason for setting all paragraphs with the ‘keep together’ attribute is that, if you edit the document after setting only some of the paragraphs with the ‘keep together’ attribute, that editing could mess up all the work you’ve already done. Personally, I’d manage the ‘keep together’ attribute via Style formatting.

              Sorry for the late reply. I tried getting back into the Lounge on Thursday but I just couldn’t get in and I was off on Friday. Both yours and Han’s suggestions make sense. I like the idea of managing them via the Style formatting. Thanks.

    Viewing 0 reply threads
    Reply To: Macro for paragraph on same page

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: