0

在我的文档中,我将 Format Page Numbers / Start at: 设置为 0,以便不计算标题页。

当我通过 VBA 执行 SaveAs 时,文档会丢失该设置!它也丢失了“不同的首页”设置,所以我直接在 VBA 中进行了设置,从而解决了这个问题。我认为,因为我在执行 SaveAs 之前通过 VBA 格式化页脚,所以我会以某种方式影响设置?无论如何,我尝试在 SaveAs 之后设置 Start At 页码,但它没有设置它。

                                ' 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

有任何想法吗?

谢谢,默里

4

1 回答 1

0

“RestartNumberingAtSection 属性,如果设置为 False,将覆盖 StartingNumber 属性,以便页码可以从上一节继续。” ( http://msdn.microsoft.com/en-us/library/office/ff821408.aspx )

因此,您必须将 RestartNumberingAtSection 属性设置为 true:

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

问候, 狮子座

于 2013-04-03T07:45:44.320 回答