Microsoft has awarded Lene Fredborg, DocTools, the Microsoft MVP award for Word each year since 2008. Link to info about the MVP Award at DocTools - document automation - add-ins, macros and document templates for Microsoft Word (logo) Document Automation
Add-ins & Macros
Document Templates
For Microsoft Word
Document automation, templates, add-ins, macros, for Microsoft Word (graphic)

Bookmark this page | Tip a friend about DocTools


Custom Search

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.

Terms of use

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. See also detailed Terms of use.

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.

The Paragraph dialog box

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.

Related information

See general information about VBA macros and code snippets, incl. information about how to install macros.

Top of page

Back to Macros...

BulletADD-INS Word add-ins ready for use - work smarter in Word

Copyright © 2006-2018 Lene Fredborg – DocTools ApS – all rights reserved | Microsoft Word Templates – add-ins – VBA macros | Save time and work more efficiently in Microsoft Word
Privacy policy | Terms of use | Cookies policy | Bookmark this page | Tip a friend | Links | Contact