#1
|
||||
|
||||
Using VBA can I animate some text in a text box?
PowerPoint is the 2019 release not part of the office 2010
I have a set of slides, 450, that are Question with 4 possible answers. All generated with VBA. The Question is placed in the title of the slide and then the four possible answers are all in one text box. At the bottom of the slide is a second text box that explains why this is the correct answer. When I add the text to the slide I know the character position (start and end) of the correct answer. I would like to add animation - on a click, to change the color of the correct answer to red. I can do it manually after the text is in the box, but it is to many slides. Note that the animation to have the why correct appear is preloaded in to the "starter slide". I tried having 4 "starter slides" that have the animation already already done, selection the correct slide, moving it to the end of the presentation, adding the text. While it works, the problem is space on the slide. I need the 4 answer text boxed separated by enough space to hold the longest answer in that position, even if for this question the answer in this position is much shorter. There is no room left to place the why this is the correct answer and it has to move to a second slide. I also tried having all the animation done on one "starter slide". The problem is once the text is loaded, each sentence (possible answer) in the text box receives the same animation. So after all of the slides have been generated, I have to manually remove 3 of the animation - the ones on the wrong answers for each slide. If you know how to remove animation #2 from shape 2 on the current slide that would solve the problem also. I would have to remove the animation is reverse sequence since the animation is renumbered when one is removed. So if C was correct, remove animation #4 then #2 and lastly #1. Deleting the animation is really some what nicer in codeing as I don't have to track the length of each answer. Last edited by Ken Leidner; 07-06-2022 at 08:50 AM. Reason: correct spelling and dropped thoughts - correct release date of PowerPoint |
#2
|
|||
|
|||
Just to check the "Answers" are separate paragraphs in one textbox / placeholder?
Assuming you have used the Timeline object to create the animations you can remove animation on a paragraph by looping back through the mainsequence and deleting if they are not the answer. Ideas for code (will need work) NOte there should be no existing animations otherwise you will need to do some math to work out which is the answer! ! Code:
Dim osld As Slide Dim oeff As Effect Dim counter As Long Dim oshp As Shape Dim ans As Long 'paragraph with answer ans = 3 'for example Set osld = ActiveWindow.View.Slide Set oshp = osld.Shapes(2) Set oeff = osld.TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectBrushOnColor, msoAnimateTextByFirstLevel, msoAnimTriggerOnPageClick) For counter = 4 To 1 Step -1 If Not counter = ans Then osld.TimeLine.MainSequence(counter).Delete Next |
#3
|
||||
|
||||
With just a few variable name changes the code worked!! It even gave me enough insight to add animation to the third shape on the slide to appear with the previous animation.
Set oshp = Sld.Shapes(3) Set oeff = Sld.TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectAppear, _ msoAnimateLevelNone, msoAnimTriggerWithPrevious) Thanks for the help!! Why did MS take away the macro recorder in PowerPoint. |
#4
|
|||
|
|||
When the macro recorder was introduced it did a pretty poor job and produced awful code. As Powerpoint got more complex over the years it really didn't work at all for the new features (like this animation!) People expected code to run in slideshow mode which it wouldn't.
|
Tags |
animation vba powerpoint |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do animate so: click on an image, then a larger image appears, then click again & text overlaid? | ship69 | PowerPoint | 1 | 09-30-2019 04:38 PM |
How do I animate so: small image ==> large image ==> text over overlaid ==> back to next image | ship69 | PowerPoint | 0 | 09-27-2019 12:55 PM |
How to animate text? | Salsa | PowerPoint | 3 | 01-13-2016 09:05 AM |
Animate a part of an equation or text | shahriar | PowerPoint | 1 | 09-20-2014 06:42 AM |
Animate text to bold then animate text to regular? | seanspotatobusiness | PowerPoint | 2 | 01-13-2011 12:08 PM |