breaklinks

  • Thread starter Thread starter timeless
  • Start date Start date
T

timeless

I would like to use this code to break links in my ppt presentations,
but it seems it works only in debug mode: (step by step)

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

any idea ?
 
Steve Rindsberg said:
Doevents
Doevents
Doevents
' in some odd instances I've needed to add as many as five of these!


' and a few more here:
Doevents
Doevents
Doevents



See new lines inserted above.
==============================

I have inserted a lot of lines in the places as you did, and now
the macro deletes some links, but not all the links.
It works well, instead, if i run it in debug mode, step by step.
What was wrong.
 
Steve Rindsberg said:
One other thing to try:

Instead of this part:


Do this:

Dim x as long

For x = oSld.Shapes.Count to 1 Step -1
Set oShp = oSld.Shapes(x)

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
' and a few more here:
Doevents
Doevents
Doevents

End If
Next oShp

Done but it gives a compilation error, it says something like
Next oShp is not allowed (may be becouse the loop begins with for x).
Can you rewrite the entire code
 
"Steve Rindsberg" <[email protected]> has written:
Post back with what you arrive at.

I have made some adjustments and this is what i have got.
This code works better that before, It deletes almost all
links but not all the links.
Then i have introduced a loop that let the macro run several times
and after that it looks like all links were finally deleted for now
(don't know in the future).


Sub BreakLinks()

For z = 1 To 10

'****************************************************

Dim oSld As Slide
Dim oShp As Shape
Dim oCmdButton As CommandBarButton
Set oCmdButton = CommandBars("Standard").Controls.Add(Id:=2956)

DoEvents
DoEvents
DoEvents
DoEvents
' in some odd instances I've needed to add as many as five of these!

ActiveWindow.ViewType = ppViewSlide

Dim x As Long

For Each oSld In ActivePresentation.Slides
For x = oSld.Shapes.Count To 1 Step -1
Set oShp = oSld.Shapes(x)

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.

' and a few more here:
DoEvents
DoEvents
DoEvents
DoEvents

End If
'Next oShp
Next

Next oSld
oCmdButton.Delete

'****************************************************

Next z

End Sub


Do you think could be something to do to let it work better.
 
Back
Top