简体   繁体   中英

Shapes (Unknown Member) Pasting from Excel into Powerpoint

I'm having an issue when trying to copy a range from Excel and paste into Powerpoint using VBA.

I receive the following error: Run-time error (80048240) Shapes (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here. Run-time error (80048240) Shapes (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here.

The error is thrown in the following code using Excel 2010 and Powerpoint 2010:

ws.Range("A1:Y" & lastRow).Copy

pApp.ActiveWindow.View.GotoSlide 2
pApp.ActiveWindow.Panes(2).Activate

With .Slides(2).Shapes
    .PasteSpecial (ppPasteHTML) `<~~~ Error occurs here!`
End With

This only occurs when using the ppPasteHTML option or the ppPasteDefault option.

The clipboard is definitely not empty and I can manually paste the range as HTML using the paste special menu option in Powerpoint which is confusing me as this is what the error indicates the issue is.

I've researched several question, none of which have helped. They indicated that I needed to activate the slide first prior to pasting which the above code will do but the error is thrown.

Can anyone suggest the reason for the error and how to resolve the issue?

I still haven't manged to solve the issue but as a work around, I'm using the following mso command:

ws.Range("A1:Y" & lastRow).Copy

pApp.ActiveWindow.View.GotoSlide 2
pApp.ActiveWindow.Panes(1).Activate

pApp.CommandBars.ExecuteMso ("Paste") '<~~ Pastes as default HTML table`

Try this (from the PowerPoint side):

   Set sld = Application.ActiveWindow.View.Slide
   ws.Range("A1:Y" & lastRow).Copy
   sld.Shapes.PasteSpecial DataType:=ppPasteHTML

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