Excel VBA 2016 Changes in Chart Commands

claywhit

New Member
Joined
Sep 5, 2016
Messages
8
Hi All,

I have an Excel VBA macro that runs perfectly fine in 2010 and 2013, however it bombs in 2016 when it encounters the setting of the plot size characteristics. Following are the specific settings in my code that give me trouble now:

.PlotArea.Width = 630
.PlotArea.Left = 30
.PlotArea.Top = 45
.PlotArea.Height = 470

Any suggestions as to the problem and how to fix.

Many thanks,
Clay
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,040
Make sure that the references to the properties are qualified with a reference to the Chart object, not the ChartObject object. Here are some examples...

Code:
With ActiveSheet.ChartObjects(1).Chart
    .PlotArea.Width = 630
    .PlotArea.Left = 30
    .PlotArea.Top = 45
    .PlotArea.Height = 470
End With
or

Code:
With Worksheets("Sheet1").ChartObjects("Chart 1").Chart
    .PlotArea.Width = 630
    .PlotArea.Left = 30
    .PlotArea.Top = 45
    .PlotArea.Height = 470
End With
Hope this helps!
 

claywhit

New Member
Joined
Sep 5, 2016
Messages
8
Domenic,

Thanks for your assistance. I intended to find a solution that still allowed my to utilize the old Charts.Add term. After some trial and error, I found out that all I needed to do was simply add a ".Activate" (i.e. ActiveChart.Activate) command ahead of the .PlotArea commands.

Thanks for your efforts.
Clay
 

Forum statistics

Threads
1,085,156
Messages
5,382,034
Members
401,767
Latest member
JohnLeek

Some videos you may like

This Week's Hot Topics

Top