简体   繁体   中英

How can I make PDF with Landscape orientation from an Excel file in Vba Access?

I used to make pdf file from Access forms using this code:

DoCmd.OutputTo acOutputForm,"FR_PFMEAPrint2", acFormatPDF,"PFMEAPrint2.PDF",   True

and I printed Excelforms with Portrait orientation in Access using this code:

Excel_App.ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

and for landscape I used this code in Access:

Forms("FR_Print").Printer.Orientation = acPRORLandscape
DoCmd.PrintOut acPages, 1, 1, , 1

but I need to output Excel file to PDF landscape format via Vba Access Thanks

You have to set the property of Excel Sheet object like shown in the sample code snippet below:

Sheets(1).PageSetup.Orientation = xlLandscape

Pertinent to your case it will look like:

Excel_App.ActiveWindow.SelectedSheets(1).PageSetup.Orientation = xlLandscape

or you can iterate through the multiple Sheets and set their property in the loop. Also, FYI: you can use underlying xlLandscape value of 2.

Hope this will help.

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