Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Word page numbers incorrect after combining documents


Reply
 
Thread Tools Display Modes
  #1  
Old 10-04-2010, 11:34 AM
Eagle72 Eagle72 is offline
Newcomer
 
Join Date: Oct 2004
Posts: 18
Default Word page numbers incorrect after combining documents


Hi,
After combining several Word documents into one master document using VBA from Excel, I find that some of them automatically restart the page numbering that I have in the master document footer. Is there a command that I can use to make sure that the page numbering of all sections that are brought in continue from the previous section? I find I can't even manually highlight the entire finished Word document and correct the page numbering. Also, the Word document template has a watermark set. Sometimes that will get removed after a certain document is inserted into the master document. I'd also love a solution for that problem.
Thanks.
Reply With Quote
  #2  
Old 10-05-2010, 09:37 AM
Tinbendr Tinbendr is offline
Freshman
 
Join Date: Jul 2010
Posts: 35
Default

What version?

The simpliest for numbering is
Code:
ActiveDocument.Repaginate
Reply With Quote
  #3  
Old 10-05-2010, 10:28 AM
Eagle72 Eagle72 is offline
Newcomer
 
Join Date: Oct 2004
Posts: 18
Default

Good question. I should have put that in my original post. I am running Office 2003. I have Excel and Word 2003 (SP3) with Visual Basic 6.5.

I tried the ActiveDocument.Repaginate (I had to code it wdApp.ActiveDocument.Repaginate because I'm controlling the Word document assembly from Excel) but it did not correct the page numbers in the footer. Some of the documents that I pull in have their own footer formatting with hard-coded starting page numbers.
Reply With Quote
  #4  
Old 10-06-2010, 02:24 PM
Tinbendr Tinbendr is offline
Freshman
 
Join Date: Jul 2010
Posts: 35
Default

try this.

Code:
Sub RenumberPages()

'from word.mvps.org

Dim StoryRng As Range
Dim LngJunk As Long

'Fix the skipped blank Header/Footer problem
LngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType

For Each StoryRng In ActiveDocument.StoryRanges
    Select Case StoryRng.StoryType
    
    Case 1, 5, 6, 7, 8, 9, 10, 11
    StoryRng.Sections(1).Footers(wdHeaderFooterPrimary).LinkToPrevious = True
    
    End Select
Next
End Sub
David
Reply With Quote
Reply

Tags
excel, numbering, page, vba, word


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->