Keeping Lines Together (Word 2007 VBA)

L

LA Lawyer

I have a multi-line text variable (an address) that Word 2007 routinely
splits between pages. How do I use VBA to instruct Word to keep those lines
together?
 
D

Doug Robbins - Word MVP

If each line of the address is in a separate paragraph, format all but the
last paragraph so that it is kept with next

Assuming that you can set a Range (rngAddress) to the address, use

For i = 1 to rngAddress.Paragraphs.Count - 1
rngAddress.Paragraphs(i).KeepWithNext = True
Next i

If it is all in one paragraph, then use

rngAddress.Paragraphs(1).KeepTogether = True


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top