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
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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!
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top