vba 获取图片的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23361823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get the size of a picture
提问by Kurt Peek
I currently have a PowerPoint macro which inserts a picture in the current slide with its original size:
我目前有一个 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
How do I 'get' the size of the image? I want to do something similar to what is described in
如何“获取”图像的大小?我想做一些类似于
Powerpoint VBA Macro to copy object's size and location and paste to another object
Powerpoint VBA 宏复制对象的大小和位置并粘贴到另一个对象
but "ShapeRange" doesn't seem to be selectable for the object I created.
但是“ShapeRange”似乎无法为我创建的对象选择。
回答by Dmitry Pavliv
Try this one:
试试这个:
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