cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Excel to PDF with pagesetup options

Frederic_Hubin
Level 2

Hey guys

I'm trying to convert excel file to pdf with specific page setup options (orientation and scaling).

I use this code, but it converts to pdf without paying attention to the options.

Dim wb as Object = GetWorkbook(handle, workbookname)
Dim excel as Object = wb.Application
Dim xlTypePDF As Integer = 0
excel.DisplayAlerts = False
wb.ActiveSheet.ExportAsFixedFormat (xlTypePDF, filename)
With wb.ActiveSheet.PageSetup
        .Orientation = 2
        .Zoom = False
        .FitToPagesWide = 1
End With
excel.DisplayAlerts = True
Any idea?
Thanks a lot
F.


------------------------------
Frédéric Hubin
------------------------------
1 BEST ANSWER

Best Answers

AbhisekhMukherj
Level 4

Hi @Frédéric Hubin

Try setting the page setup options before exporting to PDF. Let me know if that works for you. 



------------------------------
Abhisekh Mukherjee
------------------------------

View answer in original post

2 REPLIES 2

AbhisekhMukherj
Level 4

Hi @Frédéric Hubin

Try setting the page setup options before exporting to PDF. Let me know if that works for you. 



------------------------------
Abhisekh Mukherjee
------------------------------

Hello @AbhisekhMukherj

Thanks for your help here. It works for me.



------------------------------
Frédéric Hubin
------------------------------