Info

This BeforeDoubleClick event prevents the normal result of a double-click from taking place:

Private Sub xlChart_BeforeDoubleClick(ByVal ElementID As Long, _

ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean) Cancel = True End Sub

This BeforeRightClick event prevents the normal result of a right-click from taking place:

Private Sub xlChart_BeforeRightClick(Cancel As Boolean) Cancel = True End Sub

Now that the normal actions of the double-click and right-click have been controlled, ChartMouseDown rewrites what actions are initiated by a right-click and double-click of the mouse.

Private Sub xlChart_MouseDown(ByVal Button As Long, ByVal Shift As Long, _ ByVal x As Long, ByVal y As Long) If Button = 1 Then

ActiveChart.Axes(xlValue).MaximumScale = _ ActiveChart.Axes(xlValue).MaximumScale - 50 End If

If Button = 2 Then

ActiveChart.Axes(xlValue).MaximumScale = ActiveChart.Axes(xlValue).MaximumScale + 50 End If

End Sub

After the events are set in the class module, all that's left to do is declare the variable in a standard module, as follows:

Public myChartEvent As New clsEvents

Then create a procedure that will capture the events on the embedded chart (see Figure 20.5):

Sub TrapChartEvent()

Set myChartEvent.xlChart = Worksheets("EmbedChart"). _ ChartObjects("Chart Area").Chart

0 0

Post a comment