ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   Method 'Left' of object 'DataLabel' failed (https://www.excelbanter.com/charts-charting-excel/236454-method-left-object-datalabel-failed.html)

SysMod

Method 'Left' of object 'DataLabel' failed
 
So, in this chart I create datalabels and then I want them pushed far left to
the axis, so I get .left and .top and set .left to 0.

However, sometimes, .left gives me
Err -2147467259 Method 'Left' of object 'DataLabel' failed
and the return value is -1#.IND (ie Not a Number)

Some googling in MS finds a note in SP2 that
"The Trendline.DataLabel.Top and Trendline.DataLabel.Left properties of a
chart return the incorrect values if the chart has not been rendered. "

And in fact if I halt in the debugger, and check the .left, it's OK.
So I tried a retry loop using doevents and application.wait and sometimes
that works once and sometimes not.

So, how do I make sure a chart is rendered?
Is there a repaint method, a .ready property I could test and wait for, or
what?

Little point in MS telling us this can happen "if the chart has not been
rendered" without telling us how we can know when it is.

TIA
Patrick


Andy Pope

Method 'Left' of object 'DataLabel' failed
 
Hi,

There is a Refresh method.
I tested on a xy-scatter with some +14k points and did not get an error when
updating the chart, refreshing and then moving the trendline data label.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"SysMod" wrote in message
...
So, in this chart I create datalabels and then I want them pushed far left
to
the axis, so I get .left and .top and set .left to 0.

However, sometimes, .left gives me
Err -2147467259 Method 'Left' of object 'DataLabel' failed
and the return value is -1#.IND (ie Not a Number)

Some googling in MS finds a note in SP2 that
"The Trendline.DataLabel.Top and Trendline.DataLabel.Left properties of a
chart return the incorrect values if the chart has not been rendered. "

And in fact if I halt in the debugger, and check the .left, it's OK.
So I tried a retry loop using doevents and application.wait and sometimes
that works once and sometimes not.

So, how do I make sure a chart is rendered?
Is there a repaint method, a .ready property I could test and wait for, or
what?

Little point in MS telling us this can happen "if the chart has not been
rendered" without telling us how we can know when it is.

TIA
Patrick



SysMod

Method 'Left' of object 'DataLabel' failed
 
Thanks, Andy
I've noticed the 'rate' question so I'll go back and mark the previous one
too.

BTW my problem with -1.#IND was a data point that was text, not numeric :-(

All the best,
Patrick


"Andy Pope" wrote:
There is a Refresh method.




All times are GMT +1. The time now is 05:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com