Powerpoint VBA宏复制对象的大小和位置并粘贴到另一个对象 [英] Powerpoint VBA Macro to copy object's size and location and paste to another object
问题描述
仅从Windows切换到Mac,在Windows上的ppt中,我有一个插件,可以复制对象的属性(包括大小和/或位置)并将其粘贴到另一个对象,有点像具有切换功能的高级格式绘画器您要复制的属性。
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.
我没有这个插件了,但是我非常想创建一个简单的宏来复制大小和位置。这是在可能性范围内吗?如果可以,您能否提供代码或将我指向可以向我自己教书的资源?
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?
我花了大约2个小时进行搜索,但找不到与Office mac兼容的解决方案-这是我最后的希望!
I've spent about 2 hours searching and can't find an office mac compatible solution - so this is my last hope!
推荐答案
这是一个有效的示例。您可以对其进行调整以适合您的特定需求。
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
这篇关于Powerpoint VBA宏复制对象的大小和位置并粘贴到另一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!