G
George Lee
I’m changing DataLabels on a chart’s line series and keep running into the
same problem. I’ve Google’d
around but can’t find anything that solves this. On the marked line I get
the following error:
Err = -2147467259
Description: Method 'Top' of object 'DataLabel' failed
Jon Peltier has a fine answer in this group 9/4/2008. Although loading the
code with DoEvents
and Application.ScreenUpdating = True avoids that error (the On Error
statements do not get invoked), the
result is that the labels do not get moved at all. In addition, The problem
shows up while running in real
time (F5 speed) only. That is, when I stop and use the debugger and step
through the code, it works fine.
Any ideas how to stop this error?
'All points in Charts("MonthlyChart").SeriesCollection("Users") are valid.
Dim whichUser As Long
For whichUser = 1 To numberOfUsers
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).HasDataLabel = True
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Text = Worksheets("UserTable").Cells(whichUser, 1).Text
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Orientation = xlUpward
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.VerticalAlignment = xlVAlignBottom
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.HorizontalAlignment = xlHAlignLeft
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Font.Size = 9
Application.ScreenUpdating = False
DoEvents
Charts("MonthlyChart").Refresh
DoEvents
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Top = 200 '<--- Crash here.
DoEvents
Next whichUser
same problem. I’ve Google’d
around but can’t find anything that solves this. On the marked line I get
the following error:
Err = -2147467259
Description: Method 'Top' of object 'DataLabel' failed
Jon Peltier has a fine answer in this group 9/4/2008. Although loading the
code with DoEvents
and Application.ScreenUpdating = True avoids that error (the On Error
statements do not get invoked), the
result is that the labels do not get moved at all. In addition, The problem
shows up while running in real
time (F5 speed) only. That is, when I stop and use the debugger and step
through the code, it works fine.
Any ideas how to stop this error?
'All points in Charts("MonthlyChart").SeriesCollection("Users") are valid.
Dim whichUser As Long
For whichUser = 1 To numberOfUsers
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).HasDataLabel = True
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Text = Worksheets("UserTable").Cells(whichUser, 1).Text
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Orientation = xlUpward
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.VerticalAlignment = xlVAlignBottom
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.HorizontalAlignment = xlHAlignLeft
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Font.Size = 9
Application.ScreenUpdating = False
DoEvents
Charts("MonthlyChart").Refresh
DoEvents
Charts("MonthlyChart").SeriesCollection("Users").Points(whichUser).DataLabel.Top = 200 '<--- Crash here.
DoEvents
Next whichUser