Option Explicit Public WithEvents App As Application Private Sub Workbook_Open() Set App = Application End Sub
WorkbookBeforePrint
Syntax: App_WorkbookBeforePrint(Wb , Cancel)
The WorkbookBeforePrint
event occurs before printing anything from any workbook. The App_WorkbookBeforePrint
procedure has two arguments:
Wb
The workbookCancel
Setting Cancel toTrue
prevents the workbook from being printed.
App_WorkbookBeforePrint
Example:
Option Explicit Public WithEvents App As Application Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean) If Wb.Name = "brainbell.xlsm" Then Cancel = True MsgBox "Printing disalbed in Application WorkbookBeforePrint" End If End Sub Private Sub Workbook_Open() Set App = Application End Sub
The WorkbookBeforePrint
is an application-level event that affects all open workbooks in an Excel session. To work with a particular workbook use the Workbook_BeforePrint
procedure.
WorkbookModelChange
Syntax: App_WorkbookModelChange(Wb, Changes)
The
event occurs after the data model is changed. The WorkbookModelChange
App_WorkbookModelChange
procedure has two arguments:
Wb
The WorkbookChanges
The type of change that you made to the Data Model
App_WorkbookModelChange
Example:
Option Explicit Public WithEvents App As Application Private Sub App_WorkbookModelChange(ByVal Wb As Workbook, ByVal Changes As ModelChanges) MsgBox "Application WorkbookModelChange : " & Wb.Name End Sub Private Sub Workbook_Open() Set App = Application End Sub
The WorkbookModelChange
is an application-level event that affects all open workbooks in an Excel session. To work with a particular workbook use the Workbook_ModelChange
procedure.