如何 select 特定的 PowerPoint 幻灯片并复制它?

How can I select a specific PowerPoint slide and duplicate it?

我正在寻找一个简单的 VBA 代码来执行以下操作:

-> 打开特定的 PowerPoint 演示文稿(模板)

-> Select 一张特定的幻灯片然后复制它

现在我有这个

Sub pres()

    Set PowerPointApp = CreateObject("PowerPoint.Application")
    PowerPointApp.Presentations.Open "C:\Users\myname\Desktop\test.pptx"
    PowerPointApp.Visible = True
    ActivePresentation.Slides(8).Duplicate

End Sub

打开演示文稿但什么也没做,returns 给我一个错误 429。

有人知道如何完成这个非常简单的任务吗?

Presentations.Open returns 您应该捕获的 Presentation 对象,如下所示:

Sub pres()
    Dim PowerPointApp as Object
    Set PowerPointApp = CreateObject("PowerPoint.Application")

    Dim myPres as Object
    Set myPres = PowerPointApp.Presentations.Open("C:\Users\myname\Desktop\test.pptx")

    PowerPointApp.Visible = True
    myPres.Slides(8).Duplicate
End Sub