在 Excel VBA 中获取打印机选项 [英] Get Printer Options in Excel VBA
问题描述
我想在用户打印 Microsoft excel 2010 文档中的工作表前后运行一个宏.我正在使用 Workbook_BeforePrint 方法来做到这一点.我想知道的是,如何获取用户在打印工作表时已经选择的打印机选项,以便在使用 vba 打印文档时可以包含这些选项?例如,无论用户选择打印多少页,我下面的代码都只打印 1 页.我知道我可以使用 Thisworkbook.ActiveSheet.Printout 副本:=2 或类似的东西,但我不知道如何获取用户选择的页数.另外,我不确定我可能需要为印刷品包含的其他内容.我不希望用户选择更改的选项中的任何内容.如果 Microsoft 包含 Workbook_AfterPrint 方法,这会容易得多:(.提前致谢!
I have a macro that I want to run before and after a user prints a worksheet in a Microsoft excel 2010 document. I am using the Workbook_BeforePrint method to do this. What I wanted to know is, how do I get the printer options that the user already selected when they printed the worksheet, so I can include those when I print the document using vba? For instance, my code below only prints 1 page no matter how many pages the user selected to print. I know I can use Thisworkbook.ActiveSheet.Printout copies:=2 or something like that, but I don't know how to get how many pages the user selected. Also, I'm not sure of anything else I might need to include for the print. I don't want anything from the options that the user selected to change. This would have been a lot easier if Microsoft had included a Workbook_AfterPrint method :( . Thanks in advance!
这是我目前在 workbook_beforeprint 方法中的内容
Here is what I have so far inside the workbook_beforeprint method
If (ThisWorkbook.ActiveSheet.name = "Printable Schedule" And user.colorPrintable = True) Then
Application.EnableEvents = False
Application.ScreenUpdating = False
Cancel = True
user.colorPrintable = False
Call updateEmployeeShifts
ThisWorkbook.ActiveSheet.PrintOut
user.colorPrintable = True
Call updateEmployeeShifts
Application.ScreenUpdating = True
Application.EnableEvents = True
End If
推荐答案
如何只使用 Application.Dialogs(xlDialogPrinterSetup).Show
以便您可以选择所需的选项然后打印.那行得通吗?
How about just using Application.Dialogs(xlDialogPrinterSetup).Show
so that you can select the options you want and then print. Would that work?
这篇关于在 Excel VBA 中获取打印机选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!