【发布时间】:2017-11-18 12:18:41
【问题描述】:
我喜欢从 Excel 打开一个 PowerPoint 文件。 试了好几次都不行。
问题听起来与这些类似:
not able to Open Powerpoint using VBA
唯一的区别是,我得到另一个错误代码:
'Laufzeitfehler'-2147024894 (80070002)': Die Methode 'Open' für das Objekt 'Presentations' ist fehlgeschlagen.
我检查了 Microsoft PowerPoint 16.0 对象库是否已激活。我检查了几次文件路径。
有人知道错误是什么吗?
Sub sub_powerpoint_test()
Dim ObjPPT As PowerPoint.Application
Dim ObjPresentation As PowerPoint.Presentation
Dim str_FileName_PPTX As String
Set ObjPPT = CreateObject("PowerPoint.Application")
ObjPPT.Visible = msoCTrue
'Get PPT Filename
If Len(Dir(ThisWorkbook.Path & "\*.pptx")) = 0 Then
MsgBox "PPTX file does NOT exist in this folder."
Else
str_FileName_PPTX = ThisWorkbook.Path & Dir(ThisWorkbook.Path & "\*.pptx")
Debug.Print str_FileName_PPTX
End If
Set ObjPresentation = ObjPPT.Presentations.Open(str_FileName_PPTX, Untitled:=msoTrue)
End Sub
错误出现在最后的 Open 行中。
【问题讨论】:
标签: vba excel powerpoint