简体   繁体   中英

Excel set print area not affecting export as PDF layout

ExportAsFixedFormat is not following the pagesetup printarea, I tried to export with ignore print area as true and false and it didn't work.

Dim xlApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet

xlWorkBook = xlApp.Workbooks.Open(PastaLocal & "\Modelo Pedido.xlsx")
xlApp.Visible = True
xlWorkSheet = xlWorkBook.Sheets("Sheet1")

' Setting print area and exporint as PDF
xlWorkSheet.PageSetup.PrintArea = "A1:U55"
xlWorkSheet.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, PastaLocal & "\PedidoTal.pdf", False, True, False)

I have found not pre-specifying the print range works. ie

printSheet.Range("A1:AT" & lastRowinPrintSheet).ExportAsFixedFormat _ 
    Type:=xlTypePDF, _
    Filename:=scorecardFilename, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:= _
    False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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