繁体   English   中英

VBA 打印到 PDF 的代码(仅打印第 1 至 3 页)

[英]VBA code for Print to PDF (print pages 1 to 3 only)

我有以下代码,我在这里问我需要添加到代码中以仅打印第 1 到 3 页?

Sub PrintVisa()

Dim invoiceRng As Range
Dim pdfile As String
'Setting range to be printed
Set invoiceRng = Range("C7:L175")
pdfile = " Seabourn_Visa_Letter"
invoiceRng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=True, _
OpenAfterPublish:=True

请尝试下一个代码:

Sub ExportFirstThreeSheets()
  Dim FileName As String
  FileName = ThisWorkbook.Path & "\MyThreeSheets.pdf"
   Sheets(Array(1, 2, 3)).copy 'it creates a new workbook containing the first three sheets
    With ActiveWorkbook
        .ExportAsFixedFormat xlTypePDF, FileName, , , , , , True
        .Close False
    End With
End Sub

ExportAsFixedFormat 具有内置的页面范围。见下文:

Sheet5.ExportAsFixedFormat 类型:=xlTypePDF,文件名:=“YouFileName.pdf”,质量:=xlQualityStandard,IncludeDocProperties:=False,IgnorePrintAreas:=False, From:=1,To:=3, OpenAfterPublish:=True

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM