WorkbookBeforePrint Event [Excel 2003 VBA Language Reference]

Occurs before any open workbook is printed.

Private Subobject**_WorkbookBeforePrint(ByValWbAs Workbook**, ByVal Cancel As Boolean)

object An object of type Application declared with events in a class module. For more information, see Using Events with the Application Object .

Wb The workbook.

CancelFalse when the event occurs. If the event procedure sets this argument to True, the workbook isn't printed when the procedure is finished.

Example

This example recalculates all worksheets in the workbook before printing anything.

Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, _
        Cancel As Boolean)
    For Each wk in Wb.Worksheets
        wk.Calculate
    Next
End Sub

Applies to | Application Object