Microsoft Office Tutorials and References
In Depth Information
Example 21-14. The cmdCancel and cmdSetLabels Click Events
Private Sub optCopy_Click()
' Set correct check box label and enable
chkOption.Caption = "Copy Formatting"
chkOption.Accelerator = "F"
chkOption.Enabled = True
End Sub
Private Sub optLink_Click()
' Set correct check box label and enable
chkOption.Caption = "Link Number Format"
chkOption.Accelerator = "N"
chkOption.Enabled = True
End Sub
As usual, the command buttons' Click events are short. They are shown in Example 21-14 .
Example 21-14. The cmdCancel and cmdSetLabels Click Events
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdSetLabels_Click()
DoDataLabels
End Sub
The main portion of the code, the DoDataLabels procedure shown in Example 21-15 (and
housed in the UserForm module), checks to see if a data series and label range have been selected
and compares their sizes, which must match or else an error message is displayed.
Example 21-15. The DoDataLabels Procedure
Sub DoDataLabels()
Dim i As Integer
Dim rngLabels As Range
Dim fnt As Font
' Is a data series selected? Get its size.
If lstSeries.ListIndex = -1 Then
MsgBox "You must select a data series.", vbInformation
Exit Sub
Else
Set DataSeries = oChart.SeriesCollection(lstSeries.ListIndex +
1)
' There will be an error if the chart does not support data
points
On Error Resume Next
cPoints = DataSeries.Points.Count
If Err.Number <> 0 Then
MsgBox "Charts of the selected type do not support data
labels.", _
vbCritical
Unload Me
Exit Sub
End If
End If
 
 
 
 
Search JabSto ::




Custom Search