Lene Fredborg, DocTools, har hvert år siden 2008 modtaget den prestigefyldte pris som Microsoft Most Valuable Professional (MVP) i Word – link til information om MVP Award'en DocTools - dokumentautomatisering - add-ins, makroer og skabeloner til Microsoft Word (logo) Dokumentautomatisering
Add-ins & Makroer
Til Microsoft Word
Dokumentautomatisering, skabeloner (templates), add-ins og makroer til Microsoft Word (grafik)

Bogmærk denne side | Tip en ven om DocTools

Søg thedoctools.com:

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 – alle rettigheder forbeholdt | Microsoft Word skabeloner (templates) – add-ins – VBA makroer | Spar tid og arbejd mere effektivt i Microsoft Word
Privat politik | Betingelser for brug | Om cookies | Bogmærk denne side | Tip en ven | Links | Kontakt