Startup Event Handler

You write code in the Startup event handler of a worksheet when you want to perform certain actions, such as displaying text or showing controls on the actions pane when the document opens. Because Sheet1 is visible when you first open a document, you typically add this code to the Sheet1 class. Listing 7.44 shows how to add a control to the actions pane when the workbook first opens.

Listing 7.44. Displaying a control on the actions pane

Dim Sheet1Control As New MonthCalendar Private Sub Sheet1_Startup(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Startup

Globals.ThisWorkbook.ActionsPane.Controls.Add(Sheet1Control) If Globals.ThisWorkbook.ActionsPane.Controls.Count >= 1 Then

Application.CommandBars("Task Pane").Visible = True End If

0 0

Post a comment