Setting object position in PowerPoint using VBA

I use the following VBA lines to set the size / position of the selected Excel that I just pasted into PowerPoint:

Set Shp = _
PPApp.ActivePresentation.Slides( _
PPApp.ActiveWindow.Selection.SlideRange.slideindex).Shapes(3)
Shp.ScaleHeight 0.75, msoCTrue
Shp.ScaleWidth 0.75, msoCTrue
Shp.Left = 0.58
Shp.Top = 1.6

However, after running the macro, my shape has a horizontal position of 0.01 inches from the upper left corner and a vertical position of "0.02" in the upper left corner. Based on my code, the position should be 0.58 and 1.6. Any ideas on why the position is not set properly?

+4
source share
2 answers

To add to what Tim said, PowerPoint uses dots as its measurement system, at least for automation purposes, so do this instead:

Shp.Left = 0.58 * 72
Shp.Top = 1.6 * 72
+5

:

, , PowerPoint Excel. , PPApp, , Excel Office.

, Shape, with, ActiveWindow PowerPoint, ShapeRange . , , , , , , .

Sub ManipulateShapeInPowerPoint()

'Set the dimensions of the selected shape in my ACTIVE WINDOW
With PPTApp.ActiveWindow.Selection.ShapeRange
    .Height = 300
    .Width = 300
    .Align msoAlignCenters, True
    .Align msoAlignMiddles, True
End With

End Sub

YouTube, , PowerPoint, , . https://youtu.be/TyZ47qI0NkQ

-1

All Articles