Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulating mschart with vba in access: changing label position

Status
Not open for further replies.

jjd100

Programmer
May 30, 2005
19
CA
I have successfully printed a number of series in my chart in a form in MSAccess. I am trying for every third data series to post the labels to the left of the first point instead of the right. The right of the data point is the default. This can be done manually by selecting the label in design mode, clicking on "format data labels", and setting label position to "left". I have been searching for quite some time to see how to do this programatically in VBA and have only found Excel examples to do this which do not work. Also, how can I get the name of the series. Rather than the requiring that the series come in order in groups of 3 it would be better for me to have access to the series name and parse info out of that to assign color, etc.

Dim mySeries As Series
Dim seriesCol As SeriesCollection

Dim i As Integer
i = 1
Set seriesCol = GraphMonthly_graph.Object.SeriesCollection
For Each mySeries In seriesCol
Set mySeries = GraphMonthly_graph.Object.SeriesCollection(i)
mySeries.HasDataLabels = False
With mySeries
.Border.Weight = 3
.MarkerStyle = xlMarkerStyleNone ' turn off markers
If i Mod 3 = 0 Then ' need to improve this logic to use series name to determine color
.Border.ColorIndex = 10 ' green [OIL]
ElseIf i Mod 3 = 1 Then
.Border.ColorIndex = 0 ' white [LABEL]
Else
.Border.ColorIndex = 3 'red [STEAM]
End If
If i Mod 3 = 1 Then
.Points(1).ApplyDataLabels _
ShowSeriesName:=True, _
ShowCategoryName:=False, ShowValue:=False, _
AutoText:=True, LegendKey:=False
End If
End With
i = i + 1
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top