OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Break OLE links programmatically
 

Break links method isn't available in the PowerPoint object model. It is possible to break links by copying the shape to clipboard and pasting an image of the linked object using Window API and deleting the original object. There is also another way around this limitation as shown in the sample below. The snippet below converts all linked OLE objects into pictures. It executes the Break links menu item which is available in the command bar collection to convert an OLE linked shape into a picture.

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
            ' Do not forget to add this line else you will get erratic
            ' results since the code execution does not halt while menu
            ' command is executed hence we have to let the execution
            ' complete before proceeding.

            DoEvents
        End If
    Next oShp
Next oSld
oCmdButton.Delete
End Sub
 


Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.