Macro ready for use...
Macro – Keep With Next if Colon at End of Paragraph
You may want any paragraph that ends with a colon to always be on the same page as the next paragraph. You can handle this by manually applying Keep with next to all such paragraphs. However,
there is an easier way. In this article, you
will find a macro that does the work for you – it applies Keep with next to all paragraphs in the active document that end with a colon.
You are welcome to use the macros and Word tips provided on this website.
The contents is copyright. You may not reproduce any of contents (with or without modification or credits) elsewhere on the web, or on CD. Please link to the contents on this website instead.
Please note that all free Word tips, macros, add-ins and demos are provided "as is" and without obligation.
More about the Keep with next setting
In the Paragraph dialog box, on the Line and Page Breaks tab, you will find some settings that can be used to tell Word how to paginate your document.
If you turn on the Keep with next setting for a paragraph, Word will force that paragraph to always follow the next paragraph – the two paragraphs will be on the same page.
This is normally what you want to happen for a heading and the following paragraph. In general, a heading should not be the last paragraph on a page – it should always be followed by at least one paragraph.
Thus, if the paragraph after a heading moves to the next page, you want the heading to automatically follow.
You can manage this easily by making sure that all heading styles have been defined with Keep with next turned on.
However, there are other situations where Keep with next is relevant and where the style in use should not have Keep with next turned on in general.
For example, this may be the case for paragraphs that end with a colon.
Via the links below, you can view or download a macro that iterates through all paragraphs in the active document. If a colon is found
immediately before the paragraph mark or, in case of a table, before the end of cell marker, the Keep with next setting is turned on for
that paragraph. A message will appear when finished, telling how many colons were found.
See general information about VBA macros and code snippets, incl. information about how to install macros.
Top of page
Back to Macros...
ADD-INS Word add-ins ready for use - work smarter in Word