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?