#1   Report Post  
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general
Derek Hart
 
Posts: n/a
Default Automate Section Break

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


  #2   Report Post  
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general
Doug Robbins - Word MVP
 
Posts: n/a
Default Automate Section Break

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

"Derek Hart" wrote in message
...
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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of Contents Swallows Section Break TechWriterJim Microsoft Word Help 10 March 10th 06 04:28 PM
Section Breaks Question: Inserts a Continuous section break - why? Wesley45 Microsoft Word Help 3 November 7th 05 09:40 PM
Cannot delete a Section Break JMMerrick Microsoft Word Help 1 March 14th 05 11:40 PM
section break in master document Frank Drost Formatting Long Documents 1 March 3rd 05 02:58 PM
FIrst page footers Noel S Pamfree Microsoft Word Help 7 December 6th 04 08:49 PM


All times are GMT +1. The time now is 08:44 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"