VBA Excel 打印

时间:2021-11-09 15:50:52

1. 设置 页边距、打印区域

With .PageSetup
  .HeaderMargin = Application.CentimetersToPoints(0.5)
  .LeftMargin = Application.CentimetersToPoints(1.5)
  .RightMargin = Application.CentimetersToPoints(1)
  .TopMargin = Application.CentimetersToPoints(1)
  .BottomMargin = Application.CentimetersToPoints(1)
  .FooterMargin = Application.CentimetersToPoints(0.5)

  .PrintTitleRows = "$1:$3" '要打印的默认页头
  .printArea = "A4:M" & l + 1 '打印区域
End With


2. 执行打印

.Sheets("dl_1").PrintOut Copies:=2 '打印(2份)