Stopping table rows spanning pages

A

Al

I have many auto generated tables imported into WORD2002. I would like to
never have a row break across a page. I cannot do this with styles (keep
lines together or keep with next does not do it. Keep with next will work
if the table is less than 1 page in length. It will skip to next page and
put the entire table there. However, if the table is greater than 1 page,
the keep with next on every row but last cannot be honored and appears to
be ignored). The Table Properties-Row has a check box "Allow row to break
across pages", which is checked. Unchecking this does solve the problem.
Can I set the default to unchecked in my template? If so, How? Or,
Would someone kindly provide a macro which will uncheck this for every
table in a document..

Aside: Why is the k in the check box description underlined?
 
D

DA

Hi Al,
You can use the following routine to set the attribute
you want.

Private Sub TbleFormat()
Dim tblRow As Row
Dim lngCounter As Long

With ActiveDocument
For lngCounter = 1 To .Tables.Count
For Each tblRow In .Tables(lngCounter).Rows
.Tables(lngCounter).Rows(tblRow.Index). _
AllowBreakAcrossPages = False
Next tblRow
Next lngCounter
End With

End Sub
---------

Hope this solves your problem
Dennis

P.S. The underlined k is a keyboard shortcut in the
dialog.
 
J

Jezebel

A macro is easy:

Sub FixTables()

Dim pTable as Word.Table

For each pTable in ActiveDocument.Tables
pTable.Rows.AllowBreakAcrossPages = False
Next

End sub

The underlined k in Check is the hotkey for that field. Press Alt-k to use
that field without the mouse. All fields on all forms are supposed to have a
hot-key method.
 
J

Jay Freedman

Hi Al,

You can't change the default, but you can set all the rows to
nonbreaking after they're created. Here's the code you need:

Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
oTbl.Rows.AllowBreakAcrossPages = False
Next oTbl

Another approach is to create a dummy table, set its rows manually to
not break, and save it as an AutoText entry in the template. Then have
the table-generating code start each table in the document by
inserting the AutoText.

The 'k' is underlined because it's the accelerator for that field --
pressing Alt+k is the same as clicking the box.
 

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