PDA

View Full Version : Excel 2007 Plotarea.Height issue



tpoynton
01-21-2008, 02:40 PM
Greetings!

SO, I've fixed the problem, but it's odd...here's what happened. When I ran the code below, I would consistently get a 'method height of object plotarea failed' message in excel 2007; no problem in 2003. However, as soon as I clicked continue, everything works hunky dory!

SO, I figured I'd pause the code using application.wait now + 1 second, 2 seconds, 10 seconds...always with the same result - the error message. I also tried DoEvents with no luck.

What did work, however, is turning screenupdating on for this bit of code, then turning it back off (a lot of other stuff happens after this).

So, it works...but WHY? Does 2007 need to have the screen updated, at times, to have things work correctly?

here's the problematic code, with the screenupdating bits added to make it work.


'other stuff before this
Dim PieValues As Variant
PieValues = Array(totalIndTime, cnsGrpTime, dTotalCnsTime)
With ActiveSheet.ChartObjects.Add(Columns(1).Width, 180, 400, 300)
.Chart.ChartType = xlPie
.Chart.SeriesCollection.NewSeries
With .Chart.SeriesCollection(1)
.XValues = "={""Individual"",""Group"",""Other""}"
.Values = PieValues
.Explosion = 7
'.Name = "=""Total Time"""
End With
Application.ScreenUpdating = True
With .Chart.PlotArea
.Border.LineStyle = xlNone
.Interior.ColorIndex = xlNone
.Height = 180 'errored on this line before turning screenupdating on
.Width = 180
.Left = 90
.Top = 57
End With
Application.ScreenUpdating = False
'other stuff after


I'd be interested in hearing any thoughts on this, if there are any. The problem is solved, but it strikes me as odd...tim