Keep entire section in the same page

S

S Shulman

Hi

I want to make sure that an entire part of the documnet will be in the same
page and if some of it is will not fit on the same page then the entite part
of the document will move to the next page
Is there any way to do that e.g. using sections

Thank you,
Shmuel Shulman
 
S

S Shulman

Thanks for our respose,

Can I do that even if that part of the document has tables as well

I will appreciate if you can send a sample code

Cheers,
Shmuel Shulman
SBS Technologies LTD
 
J

Jonathan West

Yes, this works even if the range covered includes tables.

If you have an object variable (maybe called myRange) which covers the area
you want to keep together, then you can do it like this

With myRange.ParagraphFormat
.KeepWithNext = True
.KeepLinesTogether = True
End With

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
S

S Shulman

How can I set the range to cover a specific area that already exists

Thanks,
Shmuel Shulman
 
S

S Shulman

It is not selected, ideally I would like to expnd the document and while I
expand I want to add it to the range
And then start a new range

Cheers,
Shmuel Shulman
 
J

Jonathan West

OK, try this

Dim myRange as Range
Set myRange = ActiveDocument.Range
myRange.Collapse Direction:=wdCollapseEnd
myRange.InsertAfter "Put your new text here"
With myRange.ParagraphFormat
.KeepWithNext = True
.KeepLinesTogether = True
End With


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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