From: Terry Aney on
Well, I can't just loop through all sections and set page restart = true, b/c
they may or may not want that. I could try to check the first section of
document about to be inserted and try to set the last section (or insert a
section) of the document I'm inserting into...

Just curious why the described method from MVP isn't working :(

"Doug Robbins - Word MVP" wrote:

> The following code will set the page numbering in each section of a document
> to start at 1:
>
> Dim s As Section
> For Each s In ActiveDocument.Sections
> With s.Headers(wdHeaderFooterPrimary).PageNumbers
> .RestartNumberingAtSection = True
> .StartingNumber = 1
> End With
> Next s
>
>
> --
> Hope this helps,
>
> Doug Robbins - Word MVP
>
> Please reply only to the newsgroups unless you wish to obtain my services on
> a paid professional basis.
>
> "Terry Aney" <TerryAney(a)discussions.microsoft.com> wrote in message
> news:6F0932B4-1CAA-4EC6-903C-AD36AD04ED7E(a)microsoft.com...
> > Hi,
> >
> > I am automating Word 2007 (have tried with VBA and C#) to append several
> > documents together. These documents can have different margins,
> > headers/footers, etc.
> >
> > I have followed the procedure described by
> > http://word.mvps.org/faqs/Formatting/WorkWithSections.htm and am not
> > getting
> > the desired output.
> >
> > Given the following documents:
> >
> > Document 1 - No headers, footers without page numbers
> >
> > Document 2 - Different margins from Document 1, has no headers, but has
> > footers without page numbers.
> >
> > Document 3 - Same margins as Document 2, has no headers, but has footers
> > *with* page numbers. The first section in this document is *not* linked
> > to
> > previous section (or so Word says when I have this document opened in
> > isolation) and it has its page numbering set to restart at number 1.
> >
> > I have a loop that essentially puts the continuous section breaks at the
> > beginning and end (setting size to 1 font size so 'not noticeable') in via
> > code 'simliar' to:
> >
> > foreach document
> > call application.Selection.HomeKey(wdStory)
> > call application.Selection.InsertBreak(wdSectionBreakContinuous)
> > call application.Selection.Document.Sections(1).Range.Select
> > application.Selection.Font.Size = 1
> >
> > call application.Selection.EndKey(wdStory)
> > call application.Selection.InsertBreak(wdSectionBreakContinuous)
> > call application.Selection.Document.Sections(
> > application.Selection.Document.Sections.Count-1
> > ).Range.Characters.Last.Select
> > application.Selection.Font.Size = 1
> >
> > Then assuming I've opened Document 1, I have the following code to merge
> > the
> > three documents:
> >
> > call application.Selection.EndKey(wdStory)
> > call application.Selection.InsertBreak(wdSectionBreakNextPage)
> > call application.Selection.InsertFile("Document 2")
> > call application.Selection.EndKey(wdStory)
> > call application.Selection.InsertBreak(wdSectionBreakNextPage)
> > call application.Selection.InsertFile("Document 3")
> >
> > Everything (i.e. margins, headers and footers) looks pretty good except
> > for
> > the problem that the *first page* of 'Document 3' has a page number equal
> > to
> > the actual page that the page corresponds to in *entire* merge (i.e. page
> > 13
> > say), then the *second page* of 'Document 3' starts over at page number 2
> > and
> > continues on.
> >
> > When I examine the page numbering restart properties on the first page of
> > 'Document 3' (after the merge) the property has changed to 'Continue from
> > previous section'.
> >
> > If anyone has any suggestions I would greatly appreciate it.
>