简体   繁体   English

使用vba从Excel粘贴到powerPoint中时,仅PasteMetafilePicture有效

[英]When pasting into powerPoint from Excel using vba, only PasteMetafilePicture works

This one has me pretty confused. 这让我很困惑。 I have written a code that creates a pivot table in excel. 我写了一个代码,可以在excel中创建数据透视表。 It then creates a new PowerPoint and adjusts the formatting. 然后,它创建一个新的PowerPoint并调整格式。 Finally, I am hoping to take the pivot table from excel, copy it, and paste it into the PowerPoint file. 最后,我希望从excel中获取数据透视表,将其复制并粘贴到PowerPoint文件中。 I want to be able to edit it so a bitmap, picture, GIF, etc. will not work. 我希望能够对其进行编辑,因此位图,图片,GIF等将无法使用。

Everything works fine until I paste the pivot table into excel. 一切正常,直到我将数据透视表粘贴到excel中。 This pastes a picture into the PowerPoint, no problem: 这会将图片粘贴到PowerPoint中,没问题:

pt.TableRange1.Copy
newPPT.ActivePresentation.Slides(1).Shapes.PasteSpecial (ppPasteMetafilePicture)

where pt is the pivot table, and newPPT is the PowerPoint.Application 其中pt是数据透视表,而newPPT是PowerPoint.Application

This, however, does not work. 但是,这不起作用。

pt.TableRange1.Copy
newPPT.ActivePresentation.Slides(1).Shapes.PasteSpecial (ppPasteHTML)

Nothing pastes at all. 完全没有粘贴。 I have tried zooming out, moving all objects around because maybe it pasted behind everything but no luck. 我尝试过缩小,移动所有对象,因为它可能粘贴在所有东西后面,但是没有运气。 Any idea why this is happening? 知道为什么会这样吗?

Also, when I paste from the clipboard after the code has run, without re-copying the pivot table, it pastes no problem. 另外,在代码运行后从剪贴板粘贴时,无需重新复制数据透视表,则粘贴不会有问题。

Thanks 谢谢

This worked: 这工作:

pt.TableRange1.Copy
newPPT.ActiveWindow.View.PasteSpecial ppPasteHTML

I don't know why it doesn't using the shapes paste special, but this is a workaround. 我不知道为什么不使用特殊形状的粘贴,但这是一种解决方法。

Anyone know why this is the case? 有人知道为什么会这样吗?

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

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