This is the print version of this page. All content is copyright Indezine.com 2000- .



PowerPoint Programming: July 2012

Everything about PowerPoint programming including VBA, VSTO, and more.

See Also:
PowerPoint and Presenting Blog
PowerPoint and Presenting Glossary
PowerPoint and Presenting Tutorials

Subscribe to this blog



VBA Code: Remove Animations

Friday, July 20, 2012
posted by Geetesh on Friday, July 20, 2012 IST

Do you want to remove all animations from your slides? You may want to remove animations for a variety of reasons: maybe the sequencing is all messed up, and starting all over again seems like a great idea. But one look at your Animations task pane reveals tens or hundreds of animations on each slide. Is there a magic button somewhere in PowerPoint that can get rid of all animations all together?

Yes, you can do this easily in PowerPoint using some simple VBA code, as John Wilson of PowerPoint Alchemy explains. John adds that this only removes animations from individual slides, and not any animations added within the Slide Master.

First you need to know how you can run VBA scripts in PowerPoint -- then use this code. Explore the code a bit though since John has put in some helpful comments so that you can edit some values as required.

Sub Zap_Animations() 
Dim oeff As Effect 
Dim i As Integer 
Dim t As Integer 
Dim osld As Slide 
'Remove normal animations
For Each osld In ActivePresentation.Slides 
For i = osld.TimeLine.MainSequence.Count To 1 Step -1 
osld.TimeLine.MainSequence(i).Delete 
Next i 
'Remove triggers
For i = osld.TimeLine.InteractiveSequences.Count To 1 Step -1 
For t = osld.TimeLine.InteractiveSequences(i).Count To 1 Step -1 
osld.TimeLine.InteractiveSequences(i).Item(t).Delete 
Next t 
Next i 
Next osld 
End Sub 

Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint slides. Before you proceed further, it's a great idea to save your file -- be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension or PowerPoint Macro-Enabled Show with the PPSM extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the Zap_Animations macro will not work! See our PowerPoint File Formats page to learn about these file formats.

Thereafter run the macro -- more info can be found in our Use Macros and Scripts in PowerPoint tutorial.

Thank you so much, John.

We tested this code using PowerPoint 2010 for Windows.


John WilsonJohn Wilson is a Microsoft PowerPoint MVP who creates some cool add-ins for PowerPoint.

He participates in the PowerPoint newsgroups and runs the PowerPoint Alchemy site. John is based out of UK, and loves to hear from PowerPoint users about concepts and ideas to create even more PowerPoint add-ins!

Labels: , , , ,




Wednesday, July 18, 2012
posted by Geetesh on Wednesday, July 18, 2012 IST

PowerPoint Random Number GeneratorDo you want a random number generator for your PowerPoint slide? Do you want some numbers from a chosen sequence of numbers to pop up every time you click? Yes, you can do this in PowerPoint using some simple VBA code, as Steve Rindsberg of PowerPoint FAQ explains.

First you need to know how you can run VBA scripts in PowerPoint -- then use this code. Explore the code a bit though since Steve has put in some helpful comments so that you can edit some values as required.

Sub UpdateRandomNumber(oSh As Shape)
Dim X as Long
'Make the shape’s text a random number
'X or less
'Change 12 below to any number you’d like:
X = 12

oSh.TextFrame.TextRange.Text = CStr(Random(X))

'Now force PPT to go to the slide again (ie, to redraw it) so that
'the changed text appears:
SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex)

End Sub

Function Random(High As Long) As Long
'Generates a random number less than or equal to
'the value passed in High
Randomize
Random = Int((High * Rnd) + 1)
End Function

Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint slides. Before you proceed further, it's a great idea to save your file -- be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension or PowerPoint Macro-Enabled Show with the PPSM extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the Random Number Generator will not work! See our PowerPoint File Formats page to learn about these file formats.

Select any text object such as a text box or even a shape that can fit in a number. Select the text object and format it so that it uses a font size and typeface that you want -- you can make these choices even though there's no actual text in the text object yet.

Now select the text object, and access the Insert tab of the Ribbon. Click the Action button to bring up the Action Settings dialog box. Make sure you are in the Mouse Click tab of this dialog box -- now select the Run Macro radio button, and choose the UpdateRandomNumber macro. Click OK, and you are done.

Run the slide in Slide Show view, and click the text object to see a random number.

Thank you so much, Steve.

We tested this code using PowerPoint 2010 for Windows.



Steve RindsbergSteve Rindsberg has been associated with PowerPoint since the product originated more than two decades ago -- his PowerPoint FAQ site is a treasure trove of PowerPoint information. When he's not updating his site, he's creating new PowerPoint add-ins that expand possibilities within PowerPoint. Steve's also into a lot of print technology related stuff.

Labels: , , , ,





comments powered by Disqus


Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.

Home | PowerPoint | Photoshop | PowerPoint Templates | PowerPoint Tutorials | Blog | Notes | Ezine | Advertise | Feedback | Site Map | About Us | Contact Us

Link to Us | Privacy | Testimonials

PowerPoint Backgrounds | Christian PowerPoint Backgrounds | Business PowerPoint Presentation Templates

Plagiarism will be detected by Copyscape

©2000-2016, Geetesh Bajaj. All rights reserved.

since November 02, 2000