Document-Level Events Example
Document-level events allow you to customize the behavior of open documents. Follow these step-by-step instructions to customize the current spreadsheet by changing the meaning of double-clicks on spreadsheet cells. In more technical terms, this example will create event procedures for events in the STATISTICA Spreadsheet.
1) Open a spreadsheet in STATISTICA.
2) Click on the View menu, and select the Events - View code option. At this point a macro window will open allowing you to associate certain events with this spreadsheet.
3) In the macro window click on the Object combo box and select Document and on the Proc combo box and select BeforeDoubleClick. After you do this, the macro window creates the following code:
Private Sub Document_BeforeDoubleClick(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.
4) Change the code to the following:
Private Sub Document_BeforeDoubleClick(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
5) Click on Run macro (via the Run menu). At this point, the event handler is running. 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." To test this, follow the remaining steps in this example.
6) Activate the spreadsheet (by clicking on any cell) and then double-click on any cell in the spreadsheet. Instead of the default action associated with double-clicks (editing the cell), you will see a message box displayed.
7) At this point, you may wish to save the event code with the spreadsheet so that it will be run any time that spreadsheet is open. To do this, click back on the macro window and use the Save option (via the File menu) to save the event code. Now, close the macro window and activate the spreadsheet. Next, use the View menu to select the Events - Autorun option. Finally, save the spreadsheet. You can now close the spreadsheet and whenever you reopen it and double-click on a cell, the message box will be displayed.