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.
|
|
0
|
|
|
|
Reply
|
Utf
|
2/25/2010 8:50:01 PM |
|
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@discussions.microsoft.com> wrote in message
news:6F0932B4-1CAA-4EC6-903C-AD36AD04ED7E@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.
|
|
0
|
|
|
|
Reply
|
Doug
|
2/26/2010 1:04:15 AM
|
|
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@discussions.microsoft.com> wrote in message
> news:6F0932B4-1CAA-4EC6-903C-AD36AD04ED7E@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.
>
|
|
0
|
|
|
|
Reply
|
Utf
|
2/26/2010 10:29:02 PM
|
|
|
2 Replies
912 Views
(page loaded in 0.081 seconds)
Similiar Articles: Restart Numbering/Continue.... - microsoft.public.word ...Using InsertFile and Page Numbering 'Restart' behaves ... When I examine the page numbering restart properties on the first page of 'Document 3' (after the merge) the ... Numbering - Restarting numbering under different sections ...Using InsertFile and Page Numbering 'Restart' behaves ..... page numbers Document 2 - Different ... the page numbering restart ... page numbers in document with more ... Page numbers restart with continuous page break - microsoft.public ...Using InsertFile and Page Numbering 'Restart' behaves ..... have this document opened in isolation) and it has its page numbering set to restart at number 1. Restart check number - microsoft.public.greatplainsUsing InsertFile and Page Numbering 'Restart' behaves ... I could try to check the first section of document about to be inserted and ... document opened in > > isolation ... Different page numbering in sections - microsoft.public.word ...Using InsertFile and Page Numbering 'Restart' behaves ..... Document 1 - No headers, footers without page numbers Document 2 - Different margins ... Different Page Numbering Styles in same document - microsoft ...Using InsertFile and Page Numbering 'Restart' behaves ..... No headers, footers without page numbers Document 2 - Different margins from Document 1, has no headers, but ... How to put continuos page numbers in document with more sections ...Using InsertFile and Page Numbering 'Restart' behaves ... How to put continuos page numbers in document with more sections ... Using InsertFile and Page Numbering 'Restart ... Determine the page number in Word VBA - microsoft.public.word.vba ...Using InsertFile and Page Numbering 'Restart' behaves ... Hi, I am automating Word 2007 (have tried with VBA and C#) to append several documents ... documents: Document 1 ... Inserting files with different margin - microsoft.public.word ...> > > "Stefan Blom" wrote: > >> If you are using the Insert File dialog box, make sure to ... crashes when inserting headers or footers ... If you want to print page numbers ... Accessing a linked file in a Word document using VBA - microsoft ...Using InsertFile and Page Numbering 'Restart' behaves ... Hi, I am automating Word 2007 (have tried with VBA and C#) to append ... The first section in this document is ... Using InsertFile and Page Numbering 'Restart' behaves unexpectedly ...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 ... Restart Numbering/Continue.... - microsoft.public.word ...Using InsertFile and Page Numbering 'Restart' behaves ... When I examine the page numbering restart properties on the first page of 'Document 3' (after the merge) the ... Numbering - Restarting numbering under different sections ...Using InsertFile and Page Numbering 'Restart' behaves ..... page numbers Document 2 - Different ... the page numbering restart ... page numbers in document with more ... Word - ProgrammingUsing InsertFile and Page Numbering 'Restart' behaves unexpectedly: 26 Feb 2010 22:29 GMT: 2 Outlook 2007: Troubleshooting Outlook Crashes - Microsoft SupportStart Outlook 2007 by using an appropriate command line switch. Outlook 2007 has ... You may also see the following prompt when you restart Outlook after a crash: 7/20/2012 5:19:50 AM
|