Get image size

I currently have a PowerPoint macro that inserts an image into the current slide with its original size:

Sub Insert_Traverse_2()
    Dim oPic As Shape
    Set oPic = ActiveWindow.View.Slide.Shapes.AddPicture("\\nlamvfs00065\homes\nlkpec\newpic.png", False, True, 0, 0, -1, -1)
End Sub

How do I get image size? I want to do something similar to what is described in

Powerpoint VBA Macro to copy the size and location of an object and paste into another object

but "ShapeRange", apparently, cannot be selected for the object that I created.

+4
source share
1 answer

Try the following:

Sub Insert_Traverse_2()
    Dim oPic As Shape
    Set oPic = ActiveWindow.View.Slide.Shapes.AddPicture("\\nlamvfs00065\homes\nlkpec\newpic.png", False, True, 0, 0, -1, -1)
    With oPic
        MsgBox .Width
        MsgBox .Height
        MsgBox .Left
        MsgBox .Top
    End With
End Sub
+5
source

Source: https://habr.com/ru/post/1538563/


All Articles