4

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?

I've spent about 2 hours searching and can't find an office mac compatible solution - so this is my last hope!

Doc Brown
  • 19,739
  • 7
  • 52
  • 88
l85m
  • 808
  • 1
  • 10
  • 19

1 Answers1

4

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
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
  • 2
    One possible change: if the second selected shape is set to lock aspect ratio, you may get some odd results (changing the width will cause the height to change, chaning the height will then change the width too ... PPT's trying to prevent distorting the shape). If you want to allow distortion add .LockAspectRatio = False before setting the .Width. Or make it True if you want to be sure NOT to change the aspect ratio – Steve Rindsberg Jul 08 '11 at 16:33