PDA

View Full Version : [SOLVED:] Set powerpoint presentation opened from excel as active



Hansen
11-21-2016, 03:35 AM
Hello all,

I hope the following problem belongs to Excel help, as I am running the code withing excel, but it actually refers to a powerpoint presentation.

So I have an excel file, where I have a lot of charts and tables I put into a powerpoint file and are linked to the excel file. After updating all the charts and tables the powerpoint file is opened and I want to update all the links automatically.

For this I have the following code:


Private Sub CommandButton1_Click()
Dim PowerPointApp As Object
Set PowerPointApp = CreateObject("PowerPoint.Application")
PowerPointApp.Visible = True
PowerPointApp.Presentations.Open ActiveWorkbook.Path & "\Daily report courier.pptx"
ActivePresentation.UpdateLinks
End Sub


The powerpoint is opening just fine, but the links are not updated, as I believe the opened presentation is not set as active yet. It is returning the runtime error '429': ActiveX component can't create object

If I run the updatelinks command within powerpoint it works just fine, so that part seems to be correct.
From my understanding all I have to do is to set the powerpoint presentation as active, but unfortunately couldn't figure out how to do it, even with the help of google.
So maybe you guys can help me.

Thank you for all your ideas!

snb
11-21-2016, 04:27 AM
if the path & name are correct, this should suffice:


Private Sub CommandButton1_Click()
with getobject(ActiveWorkbook.Path & "\Daily report courier.pptx")
.UpdateLinks
.application.Visible = True
end with
End Sub

Hansen
11-21-2016, 04:59 AM
Thanks a lot!
This works perfectly!