简体   繁体   中英

When pasting into powerPoint from Excel using vba, only PasteMetafilePicture works

This one has me pretty confused. I have written a code that creates a pivot table in excel. It then creates a new PowerPoint and adjusts the formatting. Finally, I am hoping to take the pivot table from excel, copy it, and paste it into the PowerPoint file. I want to be able to edit it so a bitmap, picture, GIF, etc. will not work.

Everything works fine until I paste the pivot table into excel. This pastes a picture into the PowerPoint, no problem:

pt.TableRange1.Copy
newPPT.ActivePresentation.Slides(1).Shapes.PasteSpecial (ppPasteMetafilePicture)

where pt is the pivot table, and newPPT is the PowerPoint.Application

This, however, does not work.

pt.TableRange1.Copy
newPPT.ActivePresentation.Slides(1).Shapes.PasteSpecial (ppPasteHTML)

Nothing pastes at all. I have tried zooming out, moving all objects around because maybe it pasted behind everything but no luck. Any idea why this is happening?

Also, when I paste from the clipboard after the code has run, without re-copying the pivot table, it pastes no problem.

Thanks

This worked:

pt.TableRange1.Copy
newPPT.ActiveWindow.View.PasteSpecial ppPasteHTML

I don't know why it doesn't using the shapes paste special, but this is a workaround.

Anyone know why this is the case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM