PDA

View Full Version : Break Links Code Help



schneidm
01-26-2010, 06:39 PM
I am using this code to remove the links from my master file before saving to a new file. It works well except on the slides where I have two linked objects. It only removes the link on one of the objects on these slides. How can I modify the code to remove ALL links?

Sub BreakLinks()
Dim oSld As Slide
Dim oShp As Shape
Dim oCmdButton As CommandBarButton
Set oCmdButton = CommandBars("Standard").Controls.Add(ID:=2956)
ActiveWindow.ViewType = ppViewSlide
For Each oSld In ActivePresentation.Slides For Each oShp In
oSld.Shapes
If
oShp.Type = msoLinkedOLEObject Then ActiveWindow.View.GotoSlide
oSld.SlideIndex oShp.Select
Application.CommandBars.FindControl(ID:=2956).Execute
DoEvents
End If
Next oShp
Next oSld
oCmdButton.Delete
End Sub

John Wilson
01-27-2010, 04:06 PM
Something seems to have gone wrong with line breaks but this should work in 2003 Ithink it's pretty well the same. In 2007 you can break the link in vba without controls

Sub BreakLinks()
Dim oSld As Slide
Dim oShp As Shape
Dim oCmdButton As CommandBarButton
Set oCmdButton = CommandBars("Standard").Controls.Add(Id:=2956)
ActiveWindow.ViewType = ppViewSlide
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Type = msoLinkedOLEObject Then
ActiveWindow.View.GotoSlide (oSld.SlideIndex)
oShp.Select
Application.CommandBars.FindControl(Id:=2956).Execute
DoEvents
End If
Next oShp
Next oSld
oCmdButton.Delete
End Sub