TheWildAfrican
Board Regular
- Joined
- Apr 23, 2013
- Messages
- 70
Hello All:
I’m trying to clean up the bugs on a VBA code used for generating Monthly Graphical Report. I thought I’ve fixed all the bugs until the code started breaking on the line below (the bold red font line). The line looks good to me, but I get a Run-time error “-2147467259 (80004005)’: Unable to get the Count property of the DataLabels class. It’d be greatly appreciated if someone can help with this bug. Thanks for your anticipated help.
Best,
TheWildAfrican
Please see the code below.
Set objChart = .ChartObjects.Add(200, Top, 400, 200).Chart 'left , Top , width , height
objChart.ChartType = xlColumnClustered
objChart.SetSourceData .Range(sRange.Address), xlColumns
objChart.SeriesCollection(1).XValues = sRange.Resize(, 1)
objChart.SeriesCollection(1).Values = sRange.Resize(, 1).Offset(, 1)
objChart.SeriesCollection(2).Delete
objChart.HasTitle = True
objChart.ChartTitle.Characters.Text = "Year of Manufacture"
objChart.Location WHERE:=xlLocationAsObject, Name:="Monthly Graphical Report"
objChart.HasLegend = False
objChart.ApplyDataLabels xlDataLabelsShowLabelAndPercent, , , , , True
objChart.SeriesCollection(1).DataLabels.Font.Size = 7
objChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:= _
False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
objChart.PlotArea.ClearFormats
objChart.SeriesCollection(1).Interior.ColorIndex = 5
objChart.SeriesCollection(1).Interior.Pattern = xlSolid
objChart.ChartArea.Font.Size = 8
I’m trying to clean up the bugs on a VBA code used for generating Monthly Graphical Report. I thought I’ve fixed all the bugs until the code started breaking on the line below (the bold red font line). The line looks good to me, but I get a Run-time error “-2147467259 (80004005)’: Unable to get the Count property of the DataLabels class. It’d be greatly appreciated if someone can help with this bug. Thanks for your anticipated help.
Best,
TheWildAfrican
Please see the code below.
Set objChart = .ChartObjects.Add(200, Top, 400, 200).Chart 'left , Top , width , height
objChart.ChartType = xlColumnClustered
objChart.SetSourceData .Range(sRange.Address), xlColumns
objChart.SeriesCollection(1).XValues = sRange.Resize(, 1)
objChart.SeriesCollection(1).Values = sRange.Resize(, 1).Offset(, 1)
objChart.SeriesCollection(2).Delete
objChart.HasTitle = True
objChart.ChartTitle.Characters.Text = "Year of Manufacture"
objChart.Location WHERE:=xlLocationAsObject, Name:="Monthly Graphical Report"
objChart.HasLegend = False
objChart.ApplyDataLabels xlDataLabelsShowLabelAndPercent, , , , , True
objChart.SeriesCollection(1).DataLabels.Font.Size = 7
objChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:= _
False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
objChart.PlotArea.ClearFormats
objChart.SeriesCollection(1).Interior.ColorIndex = 5
objChart.SeriesCollection(1).Interior.Pattern = xlSolid
objChart.ChartArea.Font.Size = 8