详情: Mac的Excel文件(2016)复制到Mac地产(2016)复制Excel表格粘贴到具体的PPT幻灯片
最后,我想通过所有的表环和粘贴在它自己单独的幻灯片每个表PPT。
但首先我试图从Excel复制一个表格并粘贴到特定的PPT文件(不是网络新的演示文稿)。
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
我在做什么错?任何帮助,将不胜感激。
首先,请将OPTION EXPLICIT添加到代码模块的第一行。让它成为一种习惯,你会在生活中变得更加幸福。其次,您的PasteSpecial行使用“应用程序”,这将是Excel,但我认为您希望它是PowerPoint应用程序。使用PPT.ActiveWindow.View.PasteSpecial ... –
^^此外,我不经常使用Powerpoint VBA(即从不),但应该'PPT.Slides(2).Select'为'PPPres.Slides(2)。 Select'?我希望“幻灯片”可以是演示文稿的属性,而不是Powerpoint应用程序的属性。 – YowE3K