繁体   English   中英

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

[英]Copy Excel Table Paste to Specific PPT Slide

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

最后,我想遍历所有表格并将每个表格粘贴到 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

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

试试下面的代码(不使用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

暂无
暂无

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

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