Paste special problem

E

Edward

Hi everybody,
I'm using the following code to copy contents of slide (2) of a PPT and
paste it into my active PPT

Set oPres =
Application.Presentations.Open("C:\myDocuments\test.ppt",ReadOnly:=msoTrue,
Untitled:=msoFalse, WithWindow:=msoFalse)

oPres.Slides(2).copy

oPres.Close

ActiveWindow.View.PasteSpecial Datatype:=ppPasteMetafilePicture

sometimes the last line PPPaste fails with an error message but when I
restart my computer I works. Aslo the same code works when I paste the
content of the same slide into Word. I'm not sure why thsi happens? maybe
because of clipboard issue? I don't want to remove the ppPasteMetafilePicture
because when I uses it pictures come with corrcet size.
Any suggestions?
Thanks
 
E

Edward

Thanks Steve. I always use normal view. I have tried this code with some
modifications , so instead of copying slide I copy shaperange but still the
same problem. When this code fails I tried to see if i can pastespecial
manually and as I could guess the paste special list didn't have all other
options like windows metaafile , enhanced metaafile , .... and it was just
showing "slide" . As I said after restarting my computer or someetimes even
after closing PPT and opening it again this code works just fine and inserts
pictures as metafile.
 
E

Edward

Excellent point. You are awesome :) that was it. I have changed the code and
used shapes Pastespecial instead of views and it solved the issue but indeed
you are correct view.Pastespecial fails when we are in normal view but
clicked on a slide thumbnail.
Now , that I’m fully aware of the source of this error I can choose either
method.
Just one more question.
If I decide to go back to view.Pastespecial method what would be the code
to make sure we are on a slide and not clicked on a thumbnail?( I will put
this code before Pastspecial which will garantee the correct view)

I need to refrence that methafile to position it in a certain location on a
my slide what would be the dim statement.
dim myPic as shape
set myPic=ActiveWindow.View.PasteSpecial Datatype:=ppPasteMetafilePicture

I get type mismatch error although it seems it must be a shpe , it works
when I use object instead of shape but then I can't use .Top and .left
properties to move it to a correct location.
Do you have any suggestions?
 

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