Get Printer Options in Excel VBA

2019-09-11 19:14发布

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!

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

1条回答
家丑人穷心不美
2楼-- · 2019-09-11 19:41

How about just using Application.Dialogs(xlDialogPrinterSetup).Show so that you can select the options you want and then print. Would that work?

查看更多
登录 后发表回答