Application-Level Events Example
Application-level events allow you to customize the behavior of all documents of a certain type (such as all spreadsheets, or all workbooks, or all reports, etc.). Follow these step-by-step instructions to customize all spreadsheets by changing the meaning of double-clicks on spreadsheet cells. In more technical terms, this example will create event procedures for events in all of the Statistica Spreadsheets.
1) Click the Tools menu and select the Macro - Application Events - View Code option. At this point a macro window will open allowing you to associate certain events with all spreadsheets.
2) In the macro window click on the Object combo box and select Document and on the Proc combo box and select SpreadsheetBeforeDoubleClick. After you do this, the macro window creates the following code:
Private Sub Document_SpreadsheetBeforeDoubleClick( _ ByVal Spreadsheet As Object, ByVal Flags As Long, _ ByVal VarNo As Long, ByVal CaseNo As Long, Cancel As Boolean)
End Sub
This code is a placeholder for the event code.
3) Change the event procedure code to the following:
Private Sub Document_SpreadsheetBeforeDoubleClick( _ ByVal Spreadsheet As Object, ByVal Flags As Long, _ ByVal VarNo As Long, ByVal CaseNo As Long, Cancel As Boolean)
MsgBox "Double-clicks are not allowed here" Cancel = True
End Sub
4) Run the event handler by clicking the Run menu and then selecting the Run macro option. Hence, you have specified (via the code added in the previous step) that when you double-click on any spreadsheet cell, a message box will be displayed that says "Double-clicks are not allowed here."
5) Click the Tools menu and select the Macro - Application Events - Autorun option.
6) Close Statistica, and then open it again.
7) Finally open any spreadsheet and whenever you double-click on a cell, the message box will be displayed.