我制作了以下脚本以自动将活动工作表绘制到某个布局,在右侧页脚中我想显示活动工作表的名称,后面跟着页码,'编辑:找到&# 39; Activesheet.Name'公式,但仍然不知道如何添加页码(页码布局:实际页面数量/总页数)
想要的右脚的示例: PartA - 1/12
btw是否也可以包含一个只包含当前工作表名称的首页,以中心的大字体显示?或者是否需要设计excel工作表,使第一页只包含一个标题位于中心的活动单元格?
Application.PrintCommunication = False
Application.Dialogs(xlDialogPrinterSetup).Show
With ActiveSheet.PageSetup
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$A:$N"
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "PROJECT X"
.RightHeader = ""
.LeftFooter = Sheets("instellingen").Cells(20, 2).Value
.CenterFooter = Sheets("instellingen").Cells(22, 2).Value
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 0
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
谢谢:)
答案 0 :(得分:0)
你真的可以强制一个页码,因为你不知道有多少页。所以它与在常规Excel中设置它一样。
试试这个Page &[Page] of &[Pages]
.PageSetup
?我不记得他们是否修好了?使用Excel4宏中的打印设置速度要快得多。答案 1 :(得分:0)
当您在寻找语法时,在执行手动步骤时录制宏非常有帮助。
我使用Excel的内置Page 1 of ?
自定义过滤器来获取您所使用的语法。手动,我去了页面布局>页面设置>页眉/页脚>页脚>第1页?
.RightFooter = ActiveSheet.Name & " - " & "Page &P of &N"