0
votes

In my document I have the Format Page Numbers / Start at: set to 0 so that the title page is not counted.

When I do a SaveAs via VBA the document loses that setting! It was also losing the Different First Page setting so I set that directly in VBA which fixed that problem. I think that because I am formatting the footer via VBA before I do the SaveAs I am somehow affecting the settings? Anyway, I tried setting the Start At page number after the SaveAs but it doesnt set it.

                                ' Save our new Workbook - the output file
                            ' That makes the new file the ActiveDocument
    ActiveDocument.SaveAs filename:=fname & ".docx", FileFormat:= _
        wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _
        :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
        :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False

    ' Sets this option correctly
    ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True

    ' Problem: Doesnt set this option
    ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 0

                            ' Update the TOC
    ActiveDocument.TablesOfContents(1).Update

Any ideas?

Thanks, Murray

1

1 Answers

0
votes

"The RestartNumberingAtSection property, if set to False, will override the StartingNumber property so that page numbering can continue from the previous section." (http://msdn.microsoft.com/en-us/library/office/ff821408.aspx)

Therefore, you have to set the RestartNumberingAtSection property to true:

With ActiveDocument.Sections(1)
 .Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
 .Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 0
End With

Regards, Leo