excel宏编程如何对打印机进行设置,打印纸张,宽度,高度?

来源:百度知道 编辑:UC知道 时间:2024/06/17 04:16:44

这个都可以用宏来设置的,比如:

LeftMargin 属性
以磅为单位返回或设置左边距的大小。Double 类型,可读写。

边距的设置和返回均以磅为单位。可使用 InchesToPoints 方法进行英寸到磅值的转换,也可使用 CentimetersToPoints 方法进行厘米到磅值的转换。

示例:
将 Sheet1 的左边距设为 1.5 英寸。

Worksheets("Sheet1").PageSetup.LeftMargin = Application.InchesToPoints(1.5)

将 Sheet1 的左页边距设为 2 厘米:
Worksheets("Sheet1").PageSetup.LeftMargin = Application.CentimetersToPoints(2)

显示 Sheet1 的左边距的当前设定值:
marginInches = Worksheets("Sheet1").PageSetup.LeftMargin / _
Application.InchesToPoints(1)
MsgBox "The current left margin is " & marginInches & " inches"

再示例
设置四个边界、页眉边界、页脚边界、纸张、打印缩放比例:

With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.787)
.RightMargin = Application.InchesToPoints(1.181)
.TopMargin = Application.InchesToPoints(0.393)
.BottomMargin = Applicatio