Embedded Charts
Because embedded charts do not create chart sheets, the chart events are not as readily available. You can make them available by adding a class module.
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 = _
Worksheets(1).ChartObjects(1).Chart
End Sub
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).
Figure 8.6
Embedded chart events are now available in the class module.

Post a comment