Chart Events


This section describes some of the events associated with charts. By default, events are enabled only for charts that reside on a chart sheet. To work with events for an embedded chart, you need to create a class module.

CROSS-REFERENCE  

Refer to Chapter 18 for examples that deal with Chart events. Chapter 18 also describes how to create a class module to enable events for embedded charts.

Table 19-3 contains a list of the chart events as well as a brief description of each.

Table 19-3: EVENTS RECOGNIZED BY A CHART SHEET
Open table as spreadsheet

Event

Action That Triggers the Event

Activate

The chart sheet or embedded chart is activated.

BeforeDoubleClick

The chart sheet or an embedded chart is double-clicked. This event occurs before the default double-click action.

BeforeRightClick

The chart sheet or an embedded chart is right-clicked. The event occurs before the default right-click action.

Calculate

New or changed data is plotted on a chart.

Deactivate

The chart is deactivated.

MouseDown

A mouse button is pressed while the pointer is over a chart.

MouseMove

The position of the mouse pointer changes over a chart.

MouseUp

A mouse button is released while the pointer is over a chart.

Resize

The chart is resized.

Select

A chart element is selected.

SeriesChange

The value of a chart data point is changed.

image from book
Using the Object Browser to Locate Events

The Object Browser is a useful tool that can help you learn about objects and their properties and methods . It can also help you find out which objects support a particular event. For example, say you'd like to find out which objects support the MouseMove event. Activate the VBE and press F2 to display the Object Browser window. Make sure that <All Libraries> is selected; then type MouseMove and click the binoculars icon (see the accompanying figure).

The Object Browser displays a list of matching items. Events are indicated with a small yellow lightning bolt. From this list, you can see which objects support the MouseMove event. Most of the objects located are controls in the MSForms library, home of the UserForm control. But you can also see that Excel's Chart object supports the MouseMove event.

image from book

Notice how the list is divided into three columns: Library, Class, and Member. The match for the item that you're searching for might appear in any of these columns . This brings up a crucial point: The name of an event or term belonging to one library or class could be the same as that for another belonging to a different library or class - although they probably don't share the same functionality. So be sure to click each item in the Object Browser list and check the status bar at the bottom of the list for the syntax. You might find, for instance, that one class or library treats an event differently.

image from book
 



Excel 2007 Power Programming with VBA
Excel 2007 Power Programming with VBA (Mr. Spreadsheets Bookshelf)
ISBN: 0470044012
EAN: 2147483647
Year: 2007
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net