繁体   English   中英

无法使用 VBA 从 Excel 打开现有的 PowerPoint 演示文稿 (2016)

[英]Unable to open an existing PowerPoint Presentation (2016) from Excel using VBA

我尝试使用 Stack Overflow 上一个问题的代码片段,刚开始使用 VBA 从 Excel 打开现有 PowerPoint 文件。 示例代码片段对我不起作用。

I am using Excel 2016, and the reference object mode is Microsoft Object Model 16 Library, not the Model 12 referred to earlier. 也许这就是问题的根源。 我写的,从这个网站修改的程序是

Public Sub OpenPPT()
    Dim DestinationPPT As String
    Dim PowerPointApp As PowerPoint.Application
    Dim myPresentation As PowerPoint.Presentation

    'Easier to define manually set links up front so it's easier to change/modify
    DestinationPPT = "D:\Downloads\Automate_Excel\IR_Seeker_UpdateRevA.pptx"
    Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)
End Sub

Set myPresentation线上的常规噱头

尝试添加此行,以便在尝试在其中打开演示文稿之前打开 PowerPoint 应用程序:

Set PowerPointApp = New PowerPoint.Application

打个比方:在尝试开门之前,您需要确保自己正在看一座建筑物……

你应该改变

Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)

Set myPresentation = PowerPointApp.myPresentation.Open(DestinationPPT)

我还会在所有 subs 之外添加“选项显式”,这样如果你有一个未定义的变量以及更正一些变量拼写错误,它就会对你大喊大叫。

暂无
暂无

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

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