Hello,
Here is code I wrote to paste an excel chart that is in the clipboard. You should be able to make this work
Code:
Sub PasteFormatExcelChart()
'
' Macro created to paste an Excel Chart (Image) into PowerPoint with a maximum height of 5.9 inches.
'
' 2016-06-27 Modified for a maximum height of 5.7 and allowed the height or width
' to control the scaling.
'
Dim shapewidth As Double
Dim shapeheight As Double
Dim maxheight As Double
Dim maxwidth As Double
maxheight = 5.7 * 72 ' points
maxwidth = 9 * 72 ' points
ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
With ActiveWindow.Selection.ShapeRange
' .Fill.Transparency = 0#
.LockAspectRatio = True
shapewidth = .Width
shapeheight = .Height
If shapewidth / maxwidth > shapeheight / maxheight Then
.Width = Round(maxwidth)
shapeheight = .Height
.Left = Round(0.75 * 72)
.Top = Round(1.2 * 72) - Round((maxheight - shapeheight) / 2)
Else
.Height = Round(maxheight)
shapewidth = .Width
.Left = Round((maxwidth + 72 - shapewidth) / 2)
.Top = Round(1.2 * 72)
End If
End With
ActiveWindow.Selection.Unselect
End Sub
Michael Virostko