PDA

View Full Version : Copy and Paste Shape on same Position as Source



Dikmat
11-18-2013, 01:41 AM
Hi Guys,

I am trying to create a Macro, which copies and pastes a selected shape on the same position as the selected shape.
The pasted shape is meant to be positioned exactly over the source shape.
I am using PP2003

I never used VBA before, therefore I am completely unable to do this :(

Thank you!

John Wilson
11-18-2013, 06:05 AM
Just to check you are doing this in edit mode. The code would be quite different in show mode.

Personally I wouldn't copy paste but duplicate. I have included code for both though


Sub copy_paste()
Dim osld As Slide
Dim oshp As Shape
Dim oshpR As ShapeRange
' in case no shape is selected
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Err Then Exit Sub
oshp.Copy
Set osld = ActiveWindow.Selection.SlideRange(1)
Set oshpR = osld.Shapes.Paste
With oshpR
.Left = oshp.Left
.Top = oshp.Top
End With
End Sub


Sub cloneMe()
Dim osld As Slide
Dim oshp As Shape
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Err Then Exit Sub
With oshp.Duplicate
.Left = oshp.Left
.Top = oshp.Top
End With
End Sub

How to use code (http://www.pptalchemy.co.uk/vba.html)

Dikmat
11-18-2013, 07:35 AM
Great, thank you!