View Full Version : VBA to resize and position all charts to certain size and location
gmooney10
07-10-2014, 12:21 PM
I would like to have a macro run where I can update the size and position of charts that I paste from Excel.
I want my charts to be 6.25 x 8.6 (I do not want to lock aspect ratio) and then I want to position them at .7 and 1.05 on each page.
Some of my charts may need to be a different size so I don't want this macro to be run for every page on the presentation.
Any suggested ideas are helpful.
Thanks,
Greg
John Wilson
07-10-2014, 12:28 PM
You need to start by saying what version of Office as charts are very different after 2003.
gmooney10
07-10-2014, 12:31 PM
Apologies....2010
John Wilson
07-10-2014, 12:39 PM
This should resize a selected chart
Sub resizer()
Dim oshp As Shape
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If oshp.HasChart Then
With oshp
.LockAspectRatio = False
.Height = 6.25 * 72
.Width = 8.6 * 72
.Left = 0.7 * 72
.Top = 1.05 * 72
End With
End If
End Sub
gmooney10
07-10-2014, 12:55 PM
I added this to VBA and then selected a chart and ran the macro and nothing happened?
gmooney10
07-10-2014, 12:56 PM
I should add that the charts are actual excel linked chartsheets.
John Wilson
07-11-2014, 12:25 AM
A Linked Excel Chart Sheet is likely to return FALSE for .hasChart in Powerpoint.
Try replacing the line
If oshp.HasChart Then
With
If oshp.OLEFormat.ProgID = "Excel.Sheet.12" Then
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.