Run PPT code from excel

G

Guest

I am trying to run the following code but get this error message:
Run-Time error '429': ActiveX component can't create object
I have referenced the Microsoft PowerPoint 11.0 Object Library

Sub ChangeUpdateMode()
Dim objPPT As Object

Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.Presentations.Open ThisWorkbook.Path & "\Template.ppt"

Dim sld As Slide
Dim sh As Shape
For Each sld In ActivePresentation.Slides 'THIS LINE CAUSES ERROR
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
' Set the link to manual update mode
sh.LinkFormat.AutoUpdate = ppUpdateOptionManual
End If
Next sh
Next sld

Set objPPT = Nothing

End Sub


I also get the same error if I try to open PPT using this line of code from
Excel VBA:
PowerPoint.Application.Presentations.Open strOpenPath

Does anyone have any suggestions on how I can avoid this?

Thanks!
Dan
 
B

Bernie Deitrick

Dan,

I would try always fully qualifying the objects:

For Each sld In ActivePresentation.Slides

should be:

For Each sld In objPPT.ActivePresentation.Slides

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top