View Single Post
  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default Using InsertFile and getting Page Numbers to start at 1

Since you are doing this via code, have you tried adding code to restart
page numbering for each section?

For the best assistance, you may want to ask in a programming newsgroup such
as microsoft.public.word.vba.general.

--
Stefan Blom
Microsoft Word MVP



"Terry Aney" wrote in message
...
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...thSections.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(wdSectionBreakCo ntinuous)
call application.Selection.Document.Sections(1).Range.S elect
application.Selection.Font.Size = 1

call application.Selection.EndKey(wdStory)
call application.Selection.InsertBreak(wdSectionBreakCo ntinuous)
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(wdSectionBreakNe xtPage)
call application.Selection.InsertFile("Document 2")
call application.Selection.EndKey(wdStory)
call application.Selection.InsertBreak(wdSectionBreakNe xtPage)
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.