Automate Section Break

D

Derek Hart

Does anybody have VBA code that can show me how to combine documents. I
will be using a consistent set of styles between them. I simply want to
combine them in VBA code. I have tried the following:

With Documents(DocCombine).Content
.Collapse wdCollapseEnd
'.InsertBreak
Type:=wdSectionBreakContinuous
.InsertBreak Type:=wdPageBreak
.FormattedText =
ActiveDocument.Content.FormattedText
End With

Note that the .InsertBreak Type:=wdSectionBreakContinuous line is commented
out because I could not get the section information (such as margins) to
stay unless I put the Section Break in the document. But I am getting
strange results. My continuous section breaks are turning into page break
section breaks. Any better code to do this?

Thank You!
Derek Hart
 
D

Doug Robbins - Word MVP

Instead of inserting a continuous section break and a page break, why not
just insert a next page section break

Dim myrange As Range
DocCombine.Range.InsertBreak wdSectionBreakNextPage
Set myrange = DocCombine.Range
myrange.Start = myrange.End
myrange.FormattedText =ActiveDocument.Range.FormattedText



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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