admin 管理员组

文章数量: 887021

基本上,您将在一个页面中保留单独的行,在它们之间Word可以自由地拆分表。Here是VBA中对解决方案的描述,让我复制答案,以防链接在某个时候失效。(对于具有垂直合并单元格的表,可以通过链接找到更复杂的解决方案。)If you need to keep the whole table on a single page, format all the paragraphs except the last on each row with the 'keep with next' attribute. to do that, you might use code like:Dim Tbl As Table, lRow As Long, Rng As Range

With Tbl

lRow = .Rows.Count

Set Rng = ActiveDocument.Range(.Rows(1).Range.Start, .Rows(lRow - 1).Range.End)

.Rows.AllowBreakAcrossPages = False

.Rows.First.HeadingFormat = True

With .Range.ParagraphFormat

.SpaceBeforeAuto = False

.SpaceAfterAuto = False

.WidowControl = True

.KeepWithNext = False

.KeepTogether = False

.PageBreakBefore = False

.WordWrap = True

End With

With Rng.ParagraphFormat

.KeepWithNext = True

.KeepTogether = True

End With

End With

Set Rng = Nothing: Set Tbl = NothingThe line ' .Rows.First.HeadingFormat = True' ensures that, if the table is too long to fit on a whole page, the heading row will appear on the subsequent pages also.

本文标签: 下一页 如何在 python docx Run