0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

That worked fine, although Application.Dialogs(xlDialogPrint).Show is a little more direct.
@Jason247 yes you are right, that would be a bit more direct. Just giving you a starting point ;) glad it works for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.