1. Insert a class module.
2. Rename the module to cl_ChartEvents.
3. Enter the following line of code in the class module: Public WithEvents myChartClass As Chart
The chart events are now available to the chart, as shown in Figure 8.6. They are accessed in the class module rather than on a chart sheet.
4. Insert a standard module.
5. Enter the following lines of code in a standard module:
Dim myClassModule As New cl_ChartEvents Sub InitializeChart()
Set myClassModule.myChartClass = _
These lines initialize the embedded chart to be recognized as a chart object. The procedure must be run once per session (use Workbook_Open to automate this).
Embedded chart events are now available in the class module.
Was this article helpful?