Link to home
Start Free TrialLog in
Avatar of jm302
jm302

asked on

Excel 2007 VBA - Plot Area size not working

Hi!
  I have a worksheet with multiple types of charts (bar, line, pie). I have created VBA code that adjusts the size of the plot area when the back end data is refreshed. This is necessary because for some reason the charts plot area size will not stay after the data is refreshed, or after the workbook is closed, and re-opened. My code for the bar, and line charts works fine. The pie charts do not want to work with my code though.



Oddly enough, if I change the chart size manually in the worksheet, then run my code, the size stays, but running the code beforehand does nothing. Here is an example of my code:

The code seems to work fine in 2003. Right now I am using 2007 in compatibility mode, this is where I am having the problem.

Any help is greatly appreciated!
Thanks!
'pie charts
For a = 17 To 20
ActiveSheet.ChartObjects("Chart" & a).Activate
With ActiveChart
.PlotArea.Height = 208
.PlotArea.Top = 62
.PlotArea.Width = 208
.PlotArea.Left = 121
end with
Next

Open in new window

Avatar of bromy2004
bromy2004
Flag of Australia image

What is the Pie Chart Number?
ASKER CERTIFIED SOLUTION
Avatar of jm302
jm302

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial