简体   繁体   English

如何从 Vba Access 中的 Excel 文件制作横向 PDF?

[英]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:我曾经使用以下代码从 Access 表单制作 pdf 文件:

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

and I printed Excelforms with Portrait orientation in Access using this code:我使用以下代码在 Access 中以纵向打印 Excelforms:

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

and for landscape I used this code in Access:对于风景,我在 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但我需要通过 Vba Access 将 Excel 文件输出为 PDF 横向格式谢谢

You have to set the property of Excel Sheet object like shown in the sample code snippet below:您必须设置 Excel Sheet对象的属性,如下面的示例代码片段所示:

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.或者您可以遍历多个工作Sheets并在循环中设置它们的属性。 Also, FYI: you can use underlying xlLandscape value of 2.另外,仅供参考:您可以使用基础xlLandscape值 2。

Hope this will help.希望这会有所帮助。

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

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