Gazal
Gazal

Reputation: 184

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

Upvotes: 1

Views: 591

Answers (2)

Gazal
Gazal

Reputation: 184

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

Upvotes: 3

Mr.Burns
Mr.Burns

Reputation: 700

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

Upvotes: 0

Related Questions