Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing page break between 2 paragraphs in Word 1

Status
Not open for further replies.

dfo222

Technical User
Dec 8, 2011
4
BE
Hi,

I have a series of documents all containing lots of 2 column tables with multiple rows. Each cell in the first column contains an image with some text underneath. I want to prevent the image the text in the first column from being separated over a page - they should always stay together, no page break between them.

I tried to use 'Keep with next' in the style for the paragraph containing image but this has doesn't behave as you would expect in the table. It moves the whole table to the next page.

I tried to set 'Keep with next' on each first paragraph in the cells in the first column using VBA, with the same result.

I don't want to prevent the row from breaking across pages because the content in the second column can be very long.

My next idea was to use VBA to try to test if there is a page break between the image and the text, then if there is stop that row from breaking across the page. This is where I get stuck. I can't see how to check if there's a page break between 2 paragraphs. Any ideas how to do this?

Any other suggestions how to solve the problem very welcome.

Thanks,
Daniel
 
In the table row properties untick the 'allow break across pages' option.

combo
 
Hi combo,
Thanks for answering. The problem is I would have to do this manually in every document. I want to do this automatically for loads of documents.

I can use VBA to set every row not to break across pages, but I want to only do this in places where it's necessary, which is why I need to be able to detect somehow where this is needed. My idea was to look for a page break between the two paragraphs in the first column. Any ideas how I can do this using VBA?

Thanks,
Daniel
 
Can you embed one cell tables in first column's cells and apply the setting to embedded tables?

combo
 
I could but I still need to know which ones to apply it to, that's the critical bit. How do I know which rows/tables need to have that setting applied?
 


Why not apply to all?

If the table does not span pages, then SO WHAT?

If it does, HURRAY!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The contents in the second column can be very long, more than a page, and although I know you shouldn't do this with tables I can't change it.

I thought about Combo's suggestion a bit more and realised what he was suggesting. I've now done that and it solved the problem. I embed a single-cell table in every cell in column 1 and move the content from that cell into the embedded table. I then set 'allow break across pages' in the one row in that embedded table.

Many thanks for your suggestions.

Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top