[英]How to print some of the pages of an Excel sheet in PDF?
I have adjusted my sheet in Page Layout and have 10 pages in total.我在页面布局中调整了我的工作表,总共有 10 页。
I would like to export some of them as a PDF, for example 1, 2, 5, 8 and 10.我想将其中一些导出为 PDF,例如 1、2、5、8 和 10。
Try the Worksheet.ExportAsFixedFormat
method:尝试
Worksheet.ExportAsFixedFormat
方法:
Sub ExportPages()
Dim MyWorksheet as Worksheet
Set MyWorksheet = Application.Workbooks("NameOfYourWorkbook").Worksheets("NameOfYourWorksheet")
' This will save pages 1 and 2 in the file "Pages 1 and 2.pdf" in the current folder
MyWorksheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Pages 1 and 2", From:=1, To:=2
' Repeat this as often as you want setting different values to the options From:= and To:=
Set MyWorksheet = Nothing
End Sub
To save specific pages like 2, 5 and 7 just call the method multiple times:要保存特定页面,如 2、5 和 7,只需多次调用该方法:
MyWorksheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Page 2", From:=2, To:=2
MyWorksheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Page 5", From:=5, To:=5
MyWorksheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Page 7", From:=7, To:=7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.