{"id":475,"date":"2020-05-25T15:20:21","date_gmt":"2020-05-25T07:20:21","guid":{"rendered":"http:\/\/132.145.126.25\/?p=475"},"modified":"2020-05-27T10:29:27","modified_gmt":"2020-05-27T02:29:27","slug":"word-keep-tables-on-one-page-zh","status":"publish","type":"post","link":"https:\/\/www.tsihyoung.com\/index.php\/2020\/05\/25\/word-keep-tables-on-one-page-zh\/","title":{"rendered":"Word\u6240\u6709\u8868\u683c\u5747\u4e0d\u8de8\u9801"},"content":{"rendered":"\n<p>\u4ee5\u4e0bVBA\u4ee3\u78bc\u53ef\u4f7f\u6bcf\u500b\u8868\u683c\u53ca\u5176\u6a19\u984c\u6392\u5728\u540c\u4e00\u9801\u3002\u6211\u5011\u5047\u8a2d\u8868\u683c\u6a19\u984c\u4f4d\u65bc\u8868\u683c\u7684\u4e0a\u4e00\u6bb5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"visual-basic\" class=\"language-visual-basic\">Sub KeepRowsTogether()\nDim para As Paragraph, currCell As Cell, tabIdx As Integer\ntabIdx = 0\nFor Each para In ActiveDocument.Paragraphs\n  If para.Range.Tables.Count > 0 Then\n    If ActiveDocument.Range(0, para.Range.End).Tables.Count &lt;> tabIdx Then\n      para.Previous(1).KeepWithNext = True\n      With para.Range.Tables(1)\n        .Range.Paragraphs.KeepWithNext = True\n        If .Uniform = True Then ' No cell merged vertically\n          For Each currCell In .Rows.Last.Range.Cells ' Just set last row to false\n            currCell.Range.Paragraphs.Last.KeepWithNext = False\n          Next currCell\n        Else ' Else start from the last cell (bottom right)\n          Set currCell = .Range.Cells(.Range.Cells.Count)\n          Do While currCell.ColumnIndex > 1 ' Set all cell to false until the first column\n            currCell.Range.Paragraphs.Last.KeepWithNext = False\n            Set currCell = currCell.Previous\n          Loop\n          currCell.Range.Paragraphs.Last.KeepWithNext = False ' Set first column, last row to false\n          '    ___________\n          '   |___|___|___|\n          '   |   |___|___|\n          '   | x |___|___|\n          '   |___|_x_|_x_|\n          '    &lt;----------\n        End If\n      End With\n      tabIdx = tabIdx + 1\n    End If\n  End If\nNext para\nEnd Sub<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u53c3\u8003<\/p><cite><a href=\"https:\/\/www.msofficeforums.com\/word-vba\/6855-keeping-table-one-page.html\">https:\/\/www.msofficeforums.com\/word-vba\/6855-keeping-table-one-page.html<\/a><\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0bVBA\u4ee3\u78bc\u53ef\u4f7f\u6bcf\u500b\u8868\u683c\u53ca\u5176\u6a19\u984c\u6392\u5728\u540c\u4e00\u9801\u3002\u6211\u5011\u5047\u8a2d\u8868\u683c\u6a19\u984c\u4f4d\u65bc\u8868\u683c\u7684\u4e0a\u4e00\u6bb5\u3002 \u53c3\u8003 https:\/\/www.msofficeforums.com\/word-vba\/6855-keeping-table-one-page.html<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"post_formats":[],"languages":[6],"post_translationss":[],"class_list":["post-475","post","type-post","status-publish","format-standard","hentry","category-programme"],"guten_post_layout_featured_media_urls":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"guten_post_layout_landscape_large":false,"guten_post_layout_portrait_large":false,"guten_post_layout_square_large":false,"guten_post_layout_landscape":false,"guten_post_layout_portrait":false,"guten_post_layout_square":false,"sciencexlite-blog-thumb":false},"_links":{"self":[{"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/posts\/475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/comments?post=475"}],"version-history":[{"count":0,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/posts\/475\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/media?parent=475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/categories?post=475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/tags?post=475"},{"taxonomy":"post_format","embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/post_formats?post=475"},{"taxonomy":"language","embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/languages?post=475"},{"taxonomy":"post_translations","embeddable":true,"href":"https:\/\/www.tsihyoung.com\/index.php\/wp-json\/wp\/v2\/post_translationss?post=475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}