切换到PageSetup.CenterFooter后,PageSetup.RightFooter文本仍然保留

时间:2018-11-08 14:19:18

标签: excel vba

我将PDF页脚的代码从.RightFooter = "Page &P of &N"更改为.CenterFooter = "Page &P of &N"

现在,即使.RightFooter不再存在,“&N页面&P”也会显示在中间和右侧。

我已经删除了模块并重新创建了它。我重新启动计算机,以为它已挂在内存中。

这是我的代码。

Sub Set_PrintRnag()
Dim LstRw As Long
Dim Rng As Range
Dim strDesktop As String

strDesktop = CreateObject("WScript.Shell").SpecialFolders("Desktop")

LstRw = Sheet2.Cells(Rows.Count, "R").End(xlUp).Row
Set Rng = Sheet2.Range("R1:S" & LstRw)

With Sheet2.PageSetup
    .LeftHeader = "&C &B &20 Cohort List Report:" & Format(Date, "mm/dd/yyyy")
    .CenterFooter = "Page &P of &N"
End With

Rng.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strDesktop & "\CohortList " & " " & Format(Date, "mm-dd-yyyy") & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

End Sub

1 个答案:

答案 0 :(得分:0)

找到了我自己的答案。必须使用.RightFooter =“”。