在VBA中设定打印格式和生成PDF的设置
我在excel中添加了直接可以打印的button,但是发现不同地方的机器打印出来不同的格式,所以vba中怎么写可以设定打印的格式,包括页边距等等。。。还有指定sheet生成PDF,必须要在本机上安装PDF吗?
谢谢了。
VBA Excel --------------------编程问答-------------------- 一、页面设置参考代码
With Sheet1.PageSetup
.Orientation = xlLandscape
.LeftMargin = Application.InchesToPoints(0.2)
.RightMargin = Application.InchesToPoints(0.2)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.2)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.Zoom = 58
.PaperSize = xlPaperA4
.CenterHorizontally = True
.CenterVertically = False
End With
二、office2007以后,PDF可以直接打印:
Sheet1.ExportAsFixedFormat Type:=xlTypePDF, FileName:="aaa.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
补充:VB , VBA