Chart
| Event | Description |
| Activate Cast (ChartEvents_Event) | Occurs when an embedded chart or chart object on a chart sheet is selected. This should be used instead of the OnSheetActivate property. |
| ActivateEvent | (VSTO Only) Occurs when an embedded chart or chart object on a chart sheet is selected. |
| BeforeDoubleClick | Occurs before an embedded chart or chart object on a chart sheet is double clicked. This should be used instead of the OnDoubleClick property. |
| BeforeRightClick | Occurs before an embedded chart or chart object on a chart sheet is right clicked. |
| Calculate | Occurs before any new data is plotted or data changes. This is raised on a chart sheet that was updated because data it referenced changed. This event does not occur until the chart is forced to redraw. So if the chart is not currently visible because it is not selected or displayed in its own window the event will not be raised until the chart is visible |
| Deactivate | Occurs when a new embedded chart or chart sheet is activate and another embedded chart, chart sheet or worksheet is selected. This should be used instead of the OnSheetDeactivate property. |
| MouseDown | Occurs when a mouse button is pressed while the pointer is over an embedded chart or chart sheet. |
| MouseMove | Occurs when the mouse pointer is moved over the chart |
| MouseUp | Occurs when a mouse button is released while the pointer is over an embedded chart or chart sheet |
| Resize | Occurs when a chart is resized |
| Select Cast (ChartEvents_Event) | Occurs when a chart element is selected Raised when the selected element within a chart sheet changes. The combination of the three parameters allows you to determine exactly what element is selected. |
| SelectEvent | (VSTO Only) Occurs when a chart element is selected Raised when the selected element within a chart sheet changes. The combination of the three parameters allows you to determine exactly what element is selected. |
| SeriesChange | Occurs when a value of a chart data point changes. |
Chart - Activate
Calculate is the name of both a method and an event.
((Excel.DocEvents_Event)gApplicationExcel.ActiveChart).Activate +=
new Excel.ChartEvents_ActivateEventHandler(Event_ChartActivate);
public void Event_ChartActivate()
{
}
Addhandler CType(gApplicationExcel.ActiveChart Excel.ChartEvents_Events).Calculate
Chart - Select
Select is the name of both a method and an event.
((Excel.DocEvents_Event)gApplicationExcel.ActiveChart).Select +=
new Excel.ChartEvents_SelectEventHandler(Event_ChartSelect);
public void Event_ChartSelect()
{
}
Addhandler CType(gApplicationExcel.ActiveChart Excel.ChartEvents_Events).Select
Writing Chart Events
This object does not have events enabled by default.
You must write your own event handler routines when you want to capture chart events for embedded charts.
If you want to capture the chart events for a specific chart sheet the event handlers are available in an identical way to the worksheet level events.
The advantage of this method is that you can run the same event handler for different chart objects.
Public WithEvents ExcelChartEvents As Chart
Dim Chart1 As New EventClass
Dim Chart2 As New EventClass
Set Chart1.ExcelChartEvents = Worksheets(1).ChartObjects(1).Chart
Set Chart2.ExcelChartEvents = Worksheets(1).ChartObjects(2).Chart
Embedded Chart Events
Add a class module to trap the events
Add a standard module to hook the event handler to your charts
The exact code will depend on your situation but there are a wide range of different scenarios from all charts in all sheets in all workbooks to just a single chart in a specific workbook.
Chart Select Event
Or you can use a Chart object declared in a class module to write an event handler for both embedded charts and chart sheets.
This event has three arguments passed to it
ElementID - Identifies the chart element (xlChartItem) enumeration
Arg1 - provides additional information
| xlErrorBars | SeriesIndex |
| xlXErrorBars | SeriesIndex |
| xlYErrorBars | SeriesIndex |
| xlLegendEntry | SeriesIndex |
| xlLegendKey | SeriesIndex |
| xlUpBars | GroupIndex |
| xlDownBars | GroupIndex |
| xlSeriesLines | GroupIndex |
| xlHiLoLines | GroupIndex |
| xlDropLines | GroupIndex |
| xlRadarAxisLabels | GroupIndex |
| xlShape | ShapeIndex |
| xlPivotChartDropZone | DropZoneType |
Arg2 - provides additional information
| xlSeries | SeriesIndex | PointIndex |
| xlDataLabel | SeriesIndex | PointIndex |
| xlTrendLine | SeriesIndex | TrendLineIndex |
| xlAxis | AxisIndex | AxisType |
| xlMajorGridlines | AxisIndex | AxisType |
| xlMinorGridlines | AxisIndex | AxisType |
| xlAxisTitle | AxisIndex | AxisType |
| xlDisplayUnitLabel | AxisIndex | AxisType |
| xlPivotChartFieldButton | DropZoneType | PivotFieldIndex |
Chart MouseUp Event
This event has four arguments passed to it
Button - Identifies which button was released (xlMouseButton)
Shift - Identifies if any other keys were pressed (Ctrl, Shift, Alt)
x - Identifies the x-coordinate
y - Identifies the y-coordinate
Change Events
Change events are typically raised when a user exist cell edit mode by leaving the cell or pressing Enter
Change events can also be raised when a cell is linked to external data and it changes as a result of refreshing the external data.
Change events are not raised as a result of recalculation
Application.SheetChange
Workbook.SheetChange
Worksheet.Change
Event Procedures
Private Sub Chart_Activate()
End Sub
Private Sub Chart_BeforeDoubleClick( _
ByVal ElementID As Long, _
ByVal Arg1 As Long, _
ByVal Arg2 As Long, _
ByRef Cancel As Boolean)
End Sub
Private Sub Chart_BeforeRightClick( _
ByRef Cancel As Boolean)
End Sub
Private Sub Chart_Calculate()
End Sub
Private Sub Chart_Deactivate()
End Sub
Private Sub Chart_MouseDown( _
ByVal Button As Long, _
ByVal Shift As Long, _
ByVal x As Long, _
ByVal y As Long)
End Sub
Private Sub Chart_MouseMove( _
ByVal Button As Long, _
ByVal Shift As Long, _
ByVal x As Long, _
ByVal y As Long)
End Sub
Private Sub Chart_MouseUp( _
ByVal Button As Long, _
ByVal Shift As Long, _
ByVal x As Long, _
ByVal y As Long)
End Sub
Private Sub Chart_Resize()
End Sub
Private Sub Chart_Select( _
ByVal ElementID As Long, _
ByVal Arg1 As Long, _
ByVal Arg2 As Long)
End Sub
Private Sub Chart_SeriesChange( _
ByVal SeriesIndex As Long, _
ByVal PointIndex As Long)
End Sub
Creating Dynamically
You can create Charts dynamically
Chart controls can be positioned at arbitrary coordinates, all the other host controls must be positioned using a range.
Microsoft.Office.Tools.Excel.Chart AddChart(
double left,
double top,
double width,
double height,
string name);
Public Function AddChart( _
ByVal left As Double, _
ByVal top As Double, _
ByVal width As Double, _
ByVal height As Double, _
ByVal named As String) _
As Microsoft.Office.Tools.Excel.Chart
Microsoft.Office.Tools.Excel.Chart AddChart(
Microsoft.Office.Interop.Excel.Range range,
string name);
Public Function AddChart( _
ByVal range As Microsoft.Office.Interop.Excel.Range, _
ByVal name As String) _
As Microsoft.Office.Tools.Excel.Chart
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext