简体   繁体   中英

In MS-Word how do you VBA split a table inserting a Section Break AND a paragraph mark

wdSectionBreakNextPage does not come with a trailing paragraph mark

I have a massive table i copy from excel to word sprinkled throughout with homemade fields PAGEX and SECTIONX. My macro will change these to page and section breaks, splitting the table for each (what I want). But page breaks come with a trailing paragraph mark before the table and section breaks do not. My feeble attempts to insert a paragraph mark after a section break always ends up with the paragraph mark inside the table.

My goal is to get the same gap between my header and the beginning of the table after both section breaks and page breaks. I think I simply want a macro to insert a paragraph mark after my section breaks similar to the way wdPageBreak works (ie, between the break and the table). But I'm open to suggestions.

As perhaps further clarification, doing this manually involves creating a new row after a section break, then converting that row to text (quite impractical for the counts I'm looking at).

    Do While .Execute
        Selection.Delete
        Selection.InsertBreak Type:=wdSectionBreakNextPage
    Loop

尝试:

ActiveDocument.Compatibility(wdSplitPgBreakAndParaMark) = False

thanks free and macro. i probably should have noted that i'm a vba novice (cut-and-paste mostly). i decided it was easiest to just insert a page break after each section break, and then do a replace of ^m^p by ^p.

this works in my case, but won't work for others reading this if they have existing page breaks they don't want to lose.

GJ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM