Adding custom XYscatter labels to Excel Chart from Access VBA

D

dne

Hi all,
I have some code that adds charts to an Excel spreadsheet from an
Access database. All of the code works fine until I try to add custom
labels to an XY Scatter chart.
I have an instance of an excel application, and an instance of a
workbook. I add the chart to the sheet and then reference the chart
through the workbook (the workbook is called objXLbook, and the chart
is objXLbook("sheetname")). When I try to set the DataLabel property of
a Point within the series of the chart using

objXLbook("sheetname").SeriesCollection(1).Points(1).DataLabel.text =
"Whatever value"

I get:

Run-time error '1004'

Unable to get the DataLabel property of the Point class

When I run the same code from within Excel, it works fine.


Any ideas? I can provide the full code if necessary.

Thank in advance

David
 
D

dne

I forgot to mention:

I've also tried to instantiate a DataLabels object, and set the
datalabels to that

Dim objDataLabel as Excel.DataLabel
Set objDataLabel =
objXLbook("sheetname").SeriesC­ollection(1).Points(1).DataLab­el

and also

Set objDataLabel =
objXLbook("sheetname").SeriesC­ollection(1).DataLab­els(1)


D
 
D

dne

I found the issue. The routine was trying to label points with null
values. I added a check of the x and y value to insure that it wasn't
null, and the routine works fine now.

D
 

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