Copy from Excel to Powerpoint error

三世轮回 提交于 2019-11-28 14:33:05

The problem that you are facing is because the copying is taking time and the next line is getting executed and it doesn't find anything in the clipboard to paste.

Two ways to handle this problem

Way 1

XLApp.Range("WS1Dash").Copy
DoEvents
Set ppShape = PPSlide.Shapes.PasteSpecial(DataType:=ppPasteOLEObject, Link:=msoFalse)

Way 2

XLApp.Range("WS1Dash").Copy
Wait 2
Set ppShape = PPSlide.Shapes.PasteSpecial(DataType:=ppPasteOLEObject, Link:=msoFalse)

And paste this at the bottom of your procedure

Private Sub Wait(ByVal nSec As Long)
    nSec = nSec + Timer
    While nSec > Timer
        DoEvents
    Wend
End Sub

Lemme know if this doesn't help...

ChrCury78

I was having the same problem and it happened as I was trying to export from Excel to PowerPoint without the PowerPoint reference, using it as object. The tricky thing was that sometimes it worked, other times it won´t. So after some testing I found out that it depends on the state of the PowerPoint View, if it is showing Thumbnails or a normal Slide view.

To fix it, set the ViewType as normal before pasting.

PPAP.ActiveWindow.ViewType = ppViewNormal

or

PPAP.ActiveWindow.ViewType = 9

PPAP stands for PowerPoint Application Object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!