Copy and Paste shape as picture

B

Barb Reinhardt

I'd like to copy and paste a shape I'm calling myShape as a
ppPasteEnhancedMetafile on a slide I'm calling mySlide and then delete
myShape. I'm trying something like this:

For Each mySlide In aPPS.Slides
For Each myShape In mySlide.Shapes
If myShape.Type = 7 Then

myShape.Copy
Set newShape =
mySlide.Shapes.PasteSpecial(ppPasteEnhancedMetafile, _
msoFalse, , , , msoTrue) 'Stops here.

With newShape
.Top = myShape.Top
.Left = myShape.Left
.Height = myShape.Height
.Width = myShape.Width
End With
myShape.Delete
End If
Next myShape
Next mySlide

Can someone assist?

Thanks,
Barb Reinhardt
 
D

David M. Marcovitz

What version of PowerPoint are you using? I believe that PasteSpecial is
only available in 2003 and above.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
B

Barb Reinhardt

I'm using 2003.

David M. Marcovitz said:
What version of PowerPoint are you using? I believe that PasteSpecial is
only available in 2003 and above.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
D

David M. Marcovitz

Why is your last parameter msoTrue. That is for the link, and the help
says:

"Determines whether to create a link to the source file of the Clipboard
contents. An error occurs if the Clipboard contents do not support a
link."

It seems that you are trying to link to something (a shape copied from
PowerPoint) that cannot be linked. Try making that msoFalse instead.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
B

Barb Reinhardt

I get a type mismatch on the Set Newshape line.

David M. Marcovitz said:
Why is your last parameter msoTrue. That is for the link, and the help
says:

"Determines whether to create a link to the source file of the Clipboard
contents. An error occurs if the Clipboard contents do not support a
link."

It seems that you are trying to link to something (a shape copied from
PowerPoint) that cannot be linked. Try making that msoFalse instead.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
B

Barb Reinhardt

David,

It worked when I did the following

Dim NewShape as variant

I don't understand why it wouldn't work when it was a SHAPE.

Can you explain that?

Thanks,
Barb Reinhardt
 
D

David M. Marcovitz

Steve explained it in another response. The issue is that PasteSpecial is
returning a ShapeRange, not a Shape. If you keep myShape as a Shape and
add (1) (to get the first and only shape in that ShapeRange) to the end
of the PasteSpecial line, it will also work. I think this is better than
what you have done, not because it works better but because it will make
more sense (and down the road, you'd edit something that would break the
code in some inexplicable way because you are expecting myShape to be a
Shape).
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top