ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run PPT code from excel (https://www.excelbanter.com/excel-programming/317121-run-ppt-code-excel.html)

dan

Run PPT code from excel
 
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

Bernie Deitrick

Run PPT code from excel
 
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

"Dan" wrote in message
...
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





All times are GMT +1. The time now is 06:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com