3

I am trying to open a PowerPoint file through Excel VBA.

I get

run-time error -2147467259 (80004005)
method 'open' of object 'Presentation Failed'

This is the code

Sub createPPT(data As Workbook, ByVal pptpath As String)

Dim Sh As Shape
Dim PP As Object
Dim PPpres As Object
'Create a PP application and make it visible
Set PP = New PowerPoint.Application
PP.Visible = msoCTrue
Set PPpres = PP.Presentations.Open(pptpath)
Set Sh = data.Worksheets("Overall_Role").Shapes("Chart 3")
Sh.Copy
PPpres.Slides(6).Shapes.Paste
Set Sh = Nothing
Set PP = Nothing
Set PPpres = Nothing
End Sub

It shows the error on

Set PPpres = PP.Presentations.Open(pptpath)
1
  • You've made certain that the value in pptpath is correctly formatted and that the file's where you say it is, I'll assume. But is the file password protected and are you certain it's not corrupt? Can you doubleclick the file to open in in PPT w/o any errors? Commented May 10, 2015 at 15:41

1 Answer 1

2

Try This

Set PP = CreateObject("PowerPoint.Application")
Set PPpres = PP.Presentations.Open(pptpath)
PP.Visible = msoCTrue

Or make sure you set references Microsoft PowerPoint Object Library

Step 1

enter image description here

Step 2

enter image description here

More about object

I strongly recommend to use Option Explicit at the start of your VBA code

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.