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
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