Powerpoint VBA 宏复制对象的大小和位置并粘贴到另一个对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6620257/
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
Powerpoint VBA Macro to copy object's size and location and paste to another object
提问by l85m
Just switched to Mac from Windows and in ppt on Windows I had an addin that allowed me to copy an object's properties including size and/or location and paste it to another object, sort of like an advanced format painter with toggles for the properties you'd like to copy.
刚刚从 Windows 切换到 Mac 和 Windows 上的 ppt 我有一个插件,它允许我复制对象的属性,包括大小和/或位置并将其粘贴到另一个对象,有点像高级格式画家,可以切换您的属性我想复制。
I don't have this addin anymore, but I'd very much like to create a simple macro to copy size and location. Is this in the realm of possibility? If so could you provide the code or point me at a resource where I can teach it to myself?
我没有这个插件了,但我非常想创建一个简单的宏来复制大小和位置。这是在可能性范围内吗?如果可以,您能否提供代码或指向我可以自学的资源?
I've spent about 2 hours searching and can't find an office mac compatible solution - so this is my last hope!
我已经搜索了大约 2 个小时,但找不到与 Office mac 兼容的解决方案 - 所以这是我最后的希望!
采纳答案by Jean-Fran?ois Corbett
Here's an example that works. You can adapt it to suit your specific needs.
这是一个有效的例子。您可以对其进行调整以满足您的特定需求。
Sub CopySizeAndPosition()
' Usage: Select two shapes. The size and position of
' the first shape selected will be copied to the second.
Dim w As Double
Dim h As Double
Dim l As Double
Dim t As Double
With ActiveWindow.Selection.ShapeRange(1)
w = .Width
h = .Height
l = .Left
t = .Top
End With
With ActiveWindow.Selection.ShapeRange(2)
.Width = w
.Height = h
.Left = l
.Top = t
End With
End Sub