Reputation: 2776
I am trying to delete the shapes with animations to take slide printscreens without them. After that I want them back so I use Undo command. The problem is that this command is working to late. I mean that it makes the undo when all my vba code ends and I need it to do just when I call to the command. I am trying to stop the code for some seconds but is not working. Here is the code that I am using:
For Each sl In ActivePresentation.Slides
shapeNum = sl.Shapes.count
'ActivePresentation.Slides(1).Shapes(1).
While shapeNum <> 0
If sl.Shapes(shapeNum).AnimationSettings.Animate = msoTrue Then
animationNum = animationNum + 1
sl.Shapes(shapeNum).Delete
animationNum = animationNum + 1
End If
shapeNum = shapeNum - 1
Wend
Next
ActivePresentation.SaveAs "c:\dink_template\created_files", ppSaveAsPNG, msoTrue
If animationNum <> 0 Then
Application.CommandBars.ExecuteMso "Undo"
'to make the code stop for 5 seconds
waitTime = 5
Start = Timer
While Timer < Start + waitTime
Wend
End If
' Here the code continues doing several things
I also try to put a MsgBox or another way to stop that I saw here: http://www.pptfaq.com/FAQ00466_Put_your_macro_to_Sleep.htm
But nothing works it stay 5 seconds doing nothing but the undo doesn't work until I finish the code. What works is to use the debugger. If I stop it with the debugger it works but I want to do it without using the debugger because when I put the code as a macro I won't be able to use it.
Upvotes: 0
Views: 178
Reputation: 2776
Ok guys I think I found the solution for this. Is just to use DoEvents after Application.CommandBars.ExecuteMso "Undo" This solve the problem. Hope at least that this will help to someone.
Upvotes: 2