复制Excel表格粘贴到特定的PPT幻灯片

详情:Mac Excel(2016)复制到Mac PPT(2016)

最后,我想循环遍历所有表格,并在PPT中将每个表格粘贴到它自己的幻灯片中。

但首先我试图从Excel中复制一个表格并粘贴到特定的PPT文件(而不是networking新的演示文稿)。

Sub OpenPPTandCopySelectedTable() Dim PPT As PowerPoint.Application Set PPT = New PowerPoint.Application PPT.Visible = True 'Open the specific Template PPT.Presentations.Open Filename:="/Users/MyNameHere/Downloads/FileName.pptx" 'Make Specific File the Active Presentation Set PPPres = PPT.ActivePresentation 'Copy the Excel Table Range("Table1[#All]").Copy 'Select PowerPoint Slide number 2 PPT.Slides(2).Select 'Paste Special Application.ActiveWindow.View.PasteSpecial DataType:=ppPastePNG End Sub 

我究竟做错了什么? 任何帮助,将不胜感激。

尝试下面的代码(不使用SelectActivePresentation ,这会减慢代码的运行时间)。

 Option Explicit Sub OpenPPTandCopySelectedTable() Dim PPT As PowerPoint.Application Dim PPPres As PowerPoint.Presentation Dim myShape As Object Set PPT = New PowerPoint.Application ' Open the specific Template and set it (in 1 line) Set PPPres = PPT.Presentations.Open(Filename:="/Users/MyNameHere/Downloads/FileName.pptx", ReadOnly:=msoFalse) 'Copy the Excel Table Range("Table1[#All]").Copy ' Paste to PowerPoint and set to MyShape 'Set myShape = PPPres.Slides(2).Shapes.PasteSpecial(ppPastePNG, msoFalse) ' if you want to edit the properties 'With myShape '.Left = '.Top = 'End With ' Option 2: PPPres.Slides(2).Shapes.PasteSpecial (ppPastePNG) End Sub