设置打印机首选项 - 页面方向为横向 [英] Setting Printer Preference - Page Orientation to Landscape

查看:2923
本文介绍了设置打印机首选项 - 页面方向为横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置页面方向为横向从我的Excel VSTO项目打印Excel工作表。手动页面方向从打印机设置优先这是从'打印'的形式弹出窗口。

I would like to set the Page orientation to LandScape for printing excel worksheet from my excel Vsto project. Manually page orientation is set from the Printer Preference window which is popped up from 'Print' form.

我需要一些自动化,将方向设置为横向每一次用户给出打印命令。

I need some automation which will set the orientation to LandScape every time user gives print command.

我注意到,如果我设置方向为景观从我的Excel应用程序,它保持同样的,如果我想给在MS-Word应用程序和放大器的打印;反之亦然。因此,必须有某种标志,它可以从任何简单的WinForm应用程序被改变。

I have noticed that if i set the orientation to LandScape from my excel application, it stays same for if i want to give a print from a MS-word application & vice versa. So there has to be some kind of flag which can be changed from any simple winform application.

有什么办法我可以操控性能?

Is there any way i could manipulate the properties ?

推荐答案

我找不到任何办法,我们可以自定义任何个人打印机的打印机设置。下面是这为我工作Excel应用程序的代码。

I could not find any way we could customize the printer settings of any individual printer. Here's the code which worked for me for EXCEL application.

CommonData._WORKBOO K是一个静态的工作簿对象

CommonData._WORKBOOK is a static workbook object

Worksheet ws = CommonData._WORKBOOK.Application.ActiveSheet as Worksheet;

var _with1 = ws.PageSetup;

_with1.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
CommonData._WORKBOOK.Application.Dialogs[Microsoft.Office.Interop.Excel.XlBuiltInDialog.xlDialogPrint].Show(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

这篇关于设置打印机首选项 - 页面方向为横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆