场景:纸张是自定义的尺寸,共用一个打印模板时,在A电脑是保存的模板,A电脑能正常打印,到B电脑就不行了,默认成A4纸了,套打是要固定每页行数,每页还要有页脚。
解决方案:
1.设计一个打印样式模板
2.录制宏,获取打印模板的ID。只要是用同一台打印,打印模板ID是一样的,如果是不同的打印机,需要每台打印机录制宏,使用各自打印机对应的纸张ID
录制宏按下面视频操作,表库模板请在右侧下载。
Sub 宏1()
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = “”
.PrintTitleColumns = “”
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = “”
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = “”
.CenterHeader = “”
.RightHeader = “”
.LeftFooter = “”
.CenterFooter = “”
.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
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = 228
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False