PC Review


Reply
Thread Tools Rate Thread

Chart DataLabel Placement Error

 
 
George Lee
Guest
Posts: n/a
 
      21st Oct 2009
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
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      21st Oct 2009
If you can avoid the errors by use of DoEvents, etc., you can then try
to repeat the step that relocates the labels, or rerun the whole procedure.

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



George Lee wrote:
> 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

 
Reply With Quote
 
George Lee
Guest
Posts: n/a
 
      22nd Oct 2009
Thanks for the suggestion. Against better logic, rerunning it works better
the second time (and a third time). However, it’s still inconsistent and
items get missed each time. It looks like Microsoft needs to fix this.

"Jon Peltier" wrote:

> If you can avoid the errors by use of DoEvents, etc., you can then try
> to repeat the step that relocates the labels, or rerun the whole procedure.
>
> - Jon
> -------
> Jon Peltier
> Peltier Technical Services, Inc.
> http://peltiertech.com/
>
>
>
> George Lee wrote:
> > 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

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: DataLabel.Font.ColorIndex vs DataLabel.Text (Private Sub does not work in excel 2003) Andy Pope Microsoft Excel Charting 1 22nd Apr 2009 03:05 PM
I have a bar chart and i want to horizontaly align the datalabel =?Utf-8?B?Q2hhcmxlcw==?= Microsoft Excel Charting 1 12th Aug 2006 01:26 AM
Chart DataLabel Alignment / Word Wrap John Michl Microsoft Excel Programming 2 6th Jan 2006 02:29 PM
Adding a Chart Datalabel with a Webding John Michl Microsoft Excel Programming 2 5th Jan 2006 03:43 PM
Edit datalabel positions in a protected chart =?Utf-8?B?Sm95?= Microsoft Excel Charting 1 13th Jun 2005 08:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:00 PM.