Microsoft Office Tutorials and References
In Depth Information
Example 21-10. The Declarations Section of the basDataLabels Code Module
Next, create the dialog shown in Figure 21-34 . We have used the RefEdit control, which simulates
the Excel feature of choosing a range using the mouse. Unfortunately, this control is not
documented in the help files. (You can get a list of its properties, methods, and events in the
Microsoft Object Browser, but no help.) In any case, we are interested in only one or two
properties, as shown in the upcoming code.
The LabelDataSeries procedure, which is called when the menu item is selected, should be
placed in a new standard code module called basDataLabels . The Declarations section of the
code module has some module-level declarations, which are shown in Example 21-10 .
Example 21-10. The Declarations Section of the basDataLabels Code Module
Option Explicit
Private Type utDataLabels
HasDataLabel As Boolean
Label As String
FontName As String
FontSize As Single
Color As Long
Bold As Boolean
Italic As Boolean
End Type
Public LabelsForUndo() As utDataLabels
Public DataSeries As Series
Public cPoints As Integer
Public bCopyFormatting As Boolean
Public oChart As Chart
Dim cSeries as Long
Note, in particular, the user-defined type declaration. This saves the original data labels for a
possible Undo operation. It can hold not only the data label's text, but also the formatting options
that can be set using this utility.
The LabelDataSeries procedure, which is shown in Example 21-11 , first verifies that a chart
sheet or embedded chart is selected. Then it sets the global variable oChart to refer to this chart.
This variable will be used by the dialog, so it needs to be public. Next, it sets the global variable
cSeries to the number of data series in the chart. If the chart has no data series, a message is
displayed. If everything is satisfactory, the Set Data Labels dialog is displayed.
Example 21-11. The LabelDataSeries Procedure
Public Sub LabelDataSeries()
' Verify that a chart sheet or
' an embedded chart is active.
' If so, set it to oChart.
Set oChart = Nothing
If ActiveWorkbook.Sheets.Count = 0 Then
 
 
 
Search JabSto ::




Custom Search