【问题标题】:How can I select a specific PowerPoint slide and duplicate it?如何选择特定的 PowerPoint 幻灯片并复制它?
【发布时间】:2020-01-15 22:44:33
【问题描述】:

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

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

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

现在我有这个

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

打开演示文稿但不执行任何操作并返回错误 429。

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

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    Presentations.Open 返回一个您应该捕获的 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-08
      • 1970-01-01
      • 1970-01-01
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多