开发者

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

开发者 https://www.devze.com 2023-03-18 23:53 出处:网络
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 ad

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 advanc开发者_如何学Ced 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?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号