2014-04-29 60 views
4

我現在有一個PowerPoint宏這將插入的圖片在當前幻燈片的原始大小的尺寸:獲取圖片

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 

如何「獲取」圖像的大小?我想要做類似的東西是什麼在

Powerpoint VBA Macro to copy object's size and location and paste to another object

描述,但「ShapeRange」似乎並不爲可選擇爲我創建的對象。

回答

5

試試這個:

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 
+1

比我想象的更簡單!感謝你的回答。 –