简体   繁体   中英

how to paste table from excel to powerpoint 2007 as default using vba

I want to paste table from excel to powerpoint using vba. I am using powerpoint version 2007. I am able to successfully paste ppEnhancedmeta file. But getting problem while pasting to ppPasteDefault. ** It gives error "Shapes (unknown member): invalid request. clipboard is empty or contains data which may not be pasted here**

Sub excel_to_powerpoint()     
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Set PPApp = New PowerPoint.Application
PPApp.Visible = True
PPApp.Activate 
Set PPPres = PPApp.Presentations.Add
Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)
Sheet2.Range("A1:C5").Copy
For i = 1 To 50000: DoEvents: Next
PPSlide.Shapes.PasteSpecial ppPasteDefault
Set myshape = PPSlide.Shapes(PPSlide.Shapes.Count)
myshape.Left = 50
myshape.Top = 50
Application.CutCopyMode = False
End Sub

Somebody have any idea where i am doing wrong. Thanks

I figure it out. I don't know where the problem occur. But the solution that work for me is to replce PPSlide.Shapes.PasteSpecial ppPasteDefault with PPApp.ActiveWindow.View.PasteSpecial DataType:=ppPasteDefault

Thanks

Try

PPSlide.Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse

Instead of

PPSlide.Shapes.PasteSpecial ppPasteDefault

This works for me on MS office 2010 however I don't have 2007 as you do so this may not work.

Found this code here

Hope it helps

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