Log in

View Full Version : Update Links in PPT 2007



schneidm
05-17-2010, 06:45 AM
Hi,

I was using this code to update my Excel object links in a PPT 2003 file. It doesn't seem to work with the 2007 file. What do I need to change?

Function RefreshPPT()
Dim PPT As Object
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
PPT.Presentations.Open "myfilepath.pptm"
PPT.ActivePresentation.UpdateLinks
PPT.ActivePresentation.Save
PPT.Quit
Set PPT = Nothing
End Function

schneidm
05-18-2010, 08:20 AM
Well, I discovered this code does work, provided I have all the links set to automatic update. The problem is, when the links are set to automatic update, the "Update Links" Security Notice pops up whenever the file is opened. Can anyone tell me if I can respond to this pop-up through VBA? Bottom line is that I am trying to open the file, update the links, then close the file programmatically.

John Wilson
05-18-2010, 12:26 PM
Maybe something like this (with manual links)
Sub Relink()
Dim i As Integer
Dim s As Integer
Dim PPT As Object
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
PPT.Presentations.Open "myfilepath.pptm"
For i = 1 To PPT.ActivePresentation.Slides.Count
For s = 1 To PPT.ActivePresentation.Slides(i).Shapes.Count
If PPT.ActivePresentation.Slides(i).Shapes(s).Type = msoLinkedOLEObject Then
PPT.ActivePresentation.Slides(i).Shapes(s).LinkFormat.Update
End If
Next s
Next i
PPT.ActivePresentation.Save
PPT.Quit
End Sub

schneidm
05-18-2010, 01:35 PM
Thanks John. I'll give that a try. In the meantime I stumbled on another solution.

I found if I leave the presentation in Auto Update mode I can open the file as an "untitled" file and it doesn't give me the Security Notice pop-up. I can then use the UpdateLinks command and SaveAs the orginal file. This works great!


PPT.Presentations.Open "myfilepath.pptm", Untitled:=msoTrue
PPT.ActivePresentation.UpdateLinks
PPT.ActivePresentation.SaveAs "myfilepath.pptm"

John Wilson
05-19-2010, 12:25 AM
good find!