![]() |
|
#1
|
|||
|
|||
|
Hi all, I need to apply continuous page numbering across multiple documents. I have over 200 documents (chapters) with different authors that work on individual chapters. I can merge the documents at the end and have continuous page numbering but when I separate the documents again, the continuous page numbering is lost.
The {INCLUDETEXT} field isn't practical for me for several reasons: 1) if one or several of the chapters change, then I have to go back and manually update them again, 2) I do this task every year, so the title of the documents will change every year. I found a macro (Automatic Page Numbers across Multiple Documents (Microsoft Word)) that seems like it would work, but it gives me an error and when I debug, this is the line that is problematic: "Application.Documents(thisFile).Close Savechanges:=wdSaveChanges" Does anyone know what would cause this issue? I'm a VBA novice, so this is beyond me. I've specified my own path name and the file names for the array. This is the whole code: Code:
Sub PageNumberReset()
Dim pgNo As Long
Dim n As Long
Dim pathName As String
Dim fileNames
Dim thisFile As String
Dim aRange As Range
' Specify the path to the document files
pathName = "C:\MyDocs\Example"
' Create an array holding the document file names, in sequence
fileNames = Array("Chap1.docx", "Chap2.docx", "Chap3.docx")
pgNo = 0
For n = 0 To UBound(fileNames)
thisFile = pathName & fileNames(n)
Application.Documents.Open (thisFile)
ActiveDocument.Sections(1).Headers(1).PageNumbers.StartingNumber = pgNo + 1
Set aRange = ActiveDocument.Range
aRange.Collapse Direction:=wdCollapseEnd
aRange.Select
pgNo = Selection.Information(wdActiveEndAdjustedPageNumber)
Application.Documents(thisFile).Close Savechanges:=wdSaveChanges
Next n
End Sub
Can anyone help with this? Last edited by macropod; 05-12-2021 at 02:52 PM. Reason: Added code tags |
| Tags |
| macro, pagenumber, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Page Numbering Macro | mbr50 | Word VBA | 4 | 01-20-2020 04:47 PM |
Multiple page numbering
|
Spyke44 | Word | 4 | 10-18-2015 08:18 AM |
Run a macro on multiple documents
|
prakhil | Word VBA | 1 | 06-27-2014 06:20 AM |
| Multiple page document to individual multiple page documents | Legger | Mail Merge | 3 | 06-15-2014 06:36 AM |
page numbering across multiple documents
|
reitdesign | Word | 3 | 12-12-2008 11:55 AM |