Question : 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!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
'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

Answer : Excel 2007 VBA  - Plot Area size not working

bromy,
 
   Thanks for the suggestion, but the charts in question are all named Chart17 to 20. I actually came up with a result. It seems like it was just the loop itself that was causing the problem. I ended up just writing out the code for each individual chart and that fixed the problem. I guess the loops were just too fast for the charts.

Thanks!
Random Solutions  
 
programming4us programming4us