Loop through datalabels for eachseries in bubble chart

A

ash

Hi,

I am trying to loop through each series of a bubble chart, turn on the
datalabels for that series, and then get a reference to the first datalabel.
This code is in .net.

When I do this, on the first pass of the loop I get a reference to datalabel
1 of the first series fine, however it does not work for any other series.

My code is below...I can't figure out why it works for series 1 but not
after that.

Dim seriescol As Graph.SeriesCollection=nothing
Dim series As Graph.Series=nothing
Dim datalbls As Graph.DataLabels=nothing
Dim datalbl As Graph.DataLabel=nothing

Try
seriescol = CType(cht.SeriesCollection, Graph.SeriesCollection)

'loop through each series
For i = 1 To seriescol.Count

series = CType(seriescol.Item(i), Graph.Series)

If series.HasDataLabels = False Then
series.ApplyDataLabels (Graph.XlDataLabelsType.xlDataLabelsShowLabel)

datalbls = CType(series.DataLabels, Graph.DataLabels)

datalbls.ShowSeriesName = True

datalbl = CType(datalbls.Item(1), Graph.DataLabel)

Messagebox.Show(datalbl.Text) ‘ERROR HERE
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top