简体   繁体   English

从Excel粘贴到Powerpoint中的形状(未知成员)

[英]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. 尝试从Excel复制范围并将其粘贴到使用VBA的Powerpoint时遇到问题。

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. 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: 使用Excel 2010和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. 仅在使用ppPasteHTML选项或ppPasteDefault选项时会发生这种情况。

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. 剪贴板绝对不是空的,我可以使用Powerpoint中的“粘贴特殊菜单”选项将范围手动粘贴为HTML,这使我感到困惑,因为这是错误指示问题所在。

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: 我仍然没有解决问题的方法,但是作为一种变通方法,我正在使用以下mso命令:

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): 尝试此操作(从PowerPoint方面):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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