【发布时间】:2018-09-05 17:35:39
【问题描述】:
我正在处理一个包含打开 PowerPoint 的 Excel 文件。但是,当我运行它时,它会产生错误消息“对象演示的方法打开失败”当我单击调试时,它会突出显示“设置 myPresentation = PowerPointApp.Presentations.Open("DestinationPPT")。请帮助。任何建议都是真诚的赞赏。
'Powerpoint
Sub OpenPowerPoint()
Dim DestinationPPT As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
'Template Location variable
DestinationPPT = HOME.TextBox2.Value
DestinationPPT = DestinationPPT & "\Gemba Template.pptx"
Set PowerPointApp = CreateObject("PowerPoint.Application")
Set myPresentation = PowerPointApp.Presentations.Open("DestinationPPT")
'Transition from Excel to PowerPoint
Dim x, lastRow, slideNum As Integer
Dim cellName, shapeName, cellScore As String
【问题讨论】:
-
从
"DestinationPPT"中删除引号 - 它是一个变量,而不是字符串文字。 -
那没用 :(
-
确保
DestinationPPT是有效路径。否则,它将失败。测试debug.print DestinationPPT,看看结果如何 -
结果给出了我桌面上文件夹/项目的有效路径
-
您是否对路径有效性进行了三次检查?您可以复制/粘贴到 Windows 资源管理器并打开文件吗?因为:
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)将使用有效路径。
标签: vba excel powerpoint