chart height width VBA problem

mdavide

Board Regular
Joined
Oct 19, 2004
Messages
211
Hi all,

I've a strange problem when I try to change width/height of a graph via VBA: chart changes but with wrong values, that is I write width=77 but it sets width=21! why?
if I run step by step in debug mode, the code works fine!?!

this is my part of code

Code:
ch.Parent.Parent.Shapes(ch.Parent.Name).Top = 0
ch.Parent.Parent.Shapes(ch.Parent.Name).Left = 0
ch.Parent.Parent.Shapes(ch.Parent.Name).Width = 100
ch.Parent.Parent.Shapes(ch.Parent.Name).Height = 150

ch.PlotArea.Top = 0
ch.PlotArea.Left = 3
ch.PlotArea.Width = 77
ch.PlotArea.Height = 130

where ch is a Chart

thanks

DM
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
Are you sure the width is set to 21 afterwards? How are you testing this?
 

mdavide

Board Regular
Joined
Oct 19, 2004
Messages
211
I'm sure, I see the chart and I see in th local variables window.
I have a breakpoint at the end of the function, so I move a few steps back then run again and it works fine!
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
That sounds very weird. I wonder if the units involved change depending on what mode the code runs in? No, that would be silly.
 

mdavide

Board Regular
Joined
Oct 19, 2004
Messages
211
I know it's so strange that I can't find a solution, what I want to know is if there are known bugs of this type.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,436
Messages
5,572,094
Members
412,441
Latest member
kelethymos
Top