2017-11-18 4 views
0

Excel에서 PowerPoint 파일을 열고 싶습니다. 여러 번 시도했지만 작동하지 않습니다.VBA를 사용하여 PowerPoint 파일을 열 수 없습니다.

문제는 다음과 비슷한 소리 :

'Laufzeitfehler'-2147024894 (80070002) ': 다이 메도'열기

이 유일한 차이점은

not able to Open Powerpoint using VBA

, 나는 다른 오류 코드를 얻을 Objekt '프레 젠 테이션'ist fehlgeschlagen.

Microsoft PowerPoint 16.0 Object Library가 활성화되어 있는지 확인했습니다. 그리고 파일 경로를 여러 번 확인했습니다.

누구나 실수가있을 수 있습니다.

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 

끝에있는 열린 줄에 오류가 발생합니다.

답변

0

해결책을 찾았습니다. 문제는 경로에서 누락 된 "\"입니다.

수정 된 코드는 다음과 같습니다

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 
관련 문제