0
我喜欢从Excel打开PowerPoint文件。 我试了几次,但它不起作用。无法使用VBA打开PowerPoint文件
的问题听起来类似于这些:
not able to Open Powerpoint using VBA
唯一的区别是,我得到另一个错误代码:
'Laufzeitfehler '-2147024894(80070002)': 死了Methode' 打开'fürdas 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
该错误发生在最后的打开行中。