I have an unusual error. I have one slide with 10 trigger animations. Each animation last 2 seconds. The shapes that trigger the animation also runs a delay macro to hide the same shape based on few conditions (hence, can't use a disappear trigger animation as its disappearance is conditional).
lag = 3
start = Timer
While Timer < Start + lag
DoEvents
Wend
If disappear = True then oSh.Visible = msoFalse
The entire sequence works when I have only one slide in my presentation. As soon as I add more slides (even if it is just 1 blank slide), the animation becomes abrupt and doesn't look as intended. It looks like I'm seeing 1 frame per second.
I had encountered a similar issue earlier where the animations were compromised when a VBA Timer was run. However, I am unable to figure out why it works perfectly when I have only one slide.
Here is a video showcasing it.
Related
I have a shape named box1 in my first slide. It has no animations attached to it. However, there are other shapes on the slide that contain lots of trigger animation sequences. If I run the macro ActivePresentation.Slides(1).Shapes("box1").Top = 400 the trigger animation state doesn't change. If I had changed the colour of some other shape via the trigger animation, it stays the same. It is perfect, only the position of box1 changes.
Now, if any animation is attached to box1 and the same macro is played, the animate state of the entire slide resets.
I tried using GetClickCount but that always remained 0 as the animations were all part of trigger sequences. I would appreciate any and all help on this front.
Thank you very much.
We're developing a PowerPoint plugin, recently we got a requirement from our client to start certain functionality after animation on an object is completed but I'm not able to find any animation finished or started events.
As PeterT has mentioned, there are no events fired when shapes animate. But here's a possible workaround. It may or may not fit your needs:
Add a shape the size of the animated shape, give it a Run Macro Action Setting on mouse-over (not on click). Have it run whatever macro you've written to do what's needed.
Make the shape 99% transparent and animate it to appear automatically after the main shape you've animated.
Result: your original shape animates on, then the (for all intents) invisible add'l shape appears and as soon as the user wiggles the mouse, the macro fires.
If you can't be sure that the user will have the mouse over the shapes in question, try adding a full-slide shape instead to trigger the macro. In that case, to avoid having the macro trigger repeatedly, you might need to have the macro make the shape that triggers it invisible or have the macro remove the action setting or the like.
This may seem like a very odd thing to do in VBA but I'm curious so hear me out.
I created a procedure that moves an image across the screen when it's clicked. This works, albeit alright, but still - it works.
Here is the code:
'Start primitive animation
Private Sub imgBean_Click()
'Limit for movement to right
Dim coordinates, limit As Integer
coordinates = 0
limit = Form.Width
Do While coordinates < limit
coordinates = coordinates + 5
'Move the image
Me.imgBean.Move coordinates
'Needed to add this to see the image move - updates the form
Form.Repaint
Loop
Debug.Print "Coordinates " & coordinates
Debug.Print limit
'Reset the limit
limit = 0
End Sub
As said before the code works - but while the image is moving the screen is frozen i.e. I can't close the form or interact with other components. (This is similar to blocking the UI thread in the Android environment - something that you never do!)
So is there a way to avoid this?
Thanks
P.S. Setting the focus to the form makes the image sporadically appear and disappear.
Turns out I couldn't find a way to visually prevent interaction with the GUI once the animation has started. I said visually because it is possible to click buttons and enter input while the animation is running.
It involved the use of the DoEvents command which acts as a way of multitasking in MS Access. In mine I added the command above the Do-While loop (see below):
'Essentially allow multitasking
DoEvents
Do While coordinates < limit
coordinates = coordinates + 5
'Move the image
Me.imgBean.Move coordinates
Form.Repaint
Loop
It should be noted that it didn't work when I placed it in the Do-While loop. So, when I started the animation by clicking on the image I could still press the other buttons because I entered a value one one field and clicked a button to convert it to another - while the animation is running.
The only question is how to do this in a visual sense.
PowerPoint entrance animation set up with "Start: With Previous" starts right when a new slide is advanced. However, if you set up an exit animation in the same way, it doesn't start with a slide ending sequence. Instead, the "Start: On Click" trigger needs to be used and after your exit animation is over you still need one extra click just to advance to the next slide.
Workarounds to this are obvious: create a duplicate slide, make your ending animations from the original slide being your starting animations on the duplicate slide and let them be followed with whatever you want or create a transition slide with those ending animations only and set up "Change Advance slide -> Automatically after -> [the time it takes your animations to finish]".
These workarounds will make it work for your audience, visually. However, it has an impact on slide numbers you might need to adjust accordingly and/or duplicate content changes. If you are the only one creating and using your presentation, this might be just fine. But if you are creating a presentation in collaborative mode with three other people and don't even know who will be the presenter at the end, you can mess things up.
Let's be specific: most of my slides have 0.2s fly in entrance animation applied to blocks of content coming from right, bottom or left. Advancing to the next slide I want them to fly out in another 0.2s exit animation being followed by new slide 0.2s fly in entrance animation of the new blocks. The swapping of the blocks should be triggered while advancing to the next slide, as usually.
As mentioned, I'm not able to achieve this without one extra click between the slides.
I wrote a VBA script that should start together with an exit animation and will auto advance a slide after 0.3s when the exit animation is over. That way I should get rid of those extra clicks which are needed right now.
Sub nextslide()
iTime = 0.3
Start = Timer
While Timer < Start + iTime
DoEvents
Wend
With SlideShowWindows(1).View
.GotoSlide (ActivePresentation.SlideShowWindow.View.Slide.SlideIndex + 1)
End With
End Sub
It works well when binded on a box, button or another object. But I can't make it run on a single click (anywhere on the slide) so that it could start together with the exit animation onclick trigger. Creating a big transparent rectangular shape over the whole slide and binding the macro on it doesn't help either. By clicking it you only get the macro running, exit animation is not triggered.
Anyway, I don't want to bind the macro to any other workaround object but the slide itself.
Anyone knows how to trigger a PowerPoint VBA script on slide onclick event?
Anyone knows a secret setting that will make the exit animation work as expected i.e. animating right before exiting a slide while transitioning to the next one?
Anyone knows how to beat this dragon?
Thank you!
You could also set the TRANSITIONS (tab) -> Advance Slide After 00:00:00 seconds. You will need to set the SLIDESHOW (tab) to Use (Rehearsal) Timings. This will automatically advance the slide after the last animation action. You could, of course give it some seconds to wait, but it sounds like you just want to advance the slide.
You can intercept events in powerpoint using class module
In Class Module
In left combo (object) in VBA Explorer you can see ppt and in right your events
Private WithEvents ppt As PowerPoint.Application
In common module use
set x= new class1
Now you can use all events of presentation.
[]'s
OnSlideShowPageChange: VBA working while going to a slide without pressing any button
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = SSW.Presentation.Slides(x).SlideIndex Then
'PUT CODE HERE
End If
End Sub
Theire is a code havy workaround
You do that using the duplicate methode. However you duplicate using vba not manualy.
You can use the OnSlideShowPageChange
Test if the slide is one that need to be duplicated using a naming scheme of your choice. Then duplicate the slide. Then set the trasition effect to non and make it transition after 0 sec duration. Then remove all animations and add the exit animations desired.
Then you use the SlideShowEnd event to delete all the duplicate slides.
Note that you can use the SlideShowBegin to duplicate all the slides at once however duplicating a slide is not a fast tasck. So if you have a lot of havy slides to duplicate strating you presentation may take few seconds.
Sorry for not providing the code since it needs several lines.
For naming the slides you use also a macro.
I am creating a small applicaiton for simulating dice roll. To simulate bounces I change the position of the picture randomly. Now to simulate more than one bounce, I used a for loop to continuously change the position of the picture box. But it is not happening as I planned, the form only displays the position of the last loop. I even tried using System.Threading.Thread.Sleep(1000) hoping to show the bounces, but even they show the last loop only.
For bounceCount As Integer = 1 To bounces
bounce(pb_dice1)
bounce(pb_dice2)
System.Threading.Thread.Sleep(3000) 'I need to pause here and show the recent change in position then continue after 3 seconds
Next
the bounce method changes the position of the PictureBox.
How can I pause my for loop, display the newly positioned dices, and then continue after 3 seconds?
Controls don't refresh their graphics until event handlers finish executing. Otherwise, if several changes were made to one or more controls, they would refresh repeatedly when all you really want is the end result.
To force a control to refresh it's graphics, you need to insert the following line before sleeping:
PictureBox1.Refresh()
You may have to change PictureBox1 to the name of another control, of course. Also, it may be worth refreshing the parent control (ie. the control that contains the dice.)
I guess you should use Application.DoEvents() before calling Sleep().