I like to write talks in PowerPoint, because it has a nice interface and is a lot faster to work with for diagrams than Latex. I hope one day to move to using Google's online presentation creation tool, but there is one crucial feature missing that stops me - creating PDF's. If I am going to a place away from York, to present on another persons machine, the format I can guarantee that will display correctly is PDF.
Until now I've never written PowerPoint slides with "custom animations". A custom animation is something as simple as a slide where additional elements become visible with each click, like a pop-out box appearing or a circle around some relevant part of the slide. While its usually sufficient to get away without this feature, it is sometimes very handy. The reason I've stayed away is because of the conversion to PDF.
When Latex creates a slide with many sub-elements which appear at different stages, it creates multiple pages in the PDF. However, when using either OpenOffice's PDF converter or the Acrobat converter all the sub-elements are placed on one slide and are visible at all times - loosing the entire point of hiding elements!
I looked around the web for a tool to solve this problem, without success. I found one tool that seemed like it might help, but appeared to rely on having Acrobat Creator installed locally. I write my presentations on my machine, then remote desktop to the University machines to do the PDF conversion, and on those machines I don't have admin access. In addition, this tool required money to use, and may still not have worked.
Instead I wrote some VBA code, which deconstructs the slides with animations into multiple slides, then puts them back together after. The two macro's are called AddElements and RemElements. The code to AddElements cycles through each slide, duplicating it once for each level of clicky-ness in the animation, deleting the elements that shouldn't be visible yet, and hiding the original.
To run the code go to Tools/Macro/Visual Basic Editor, copy and paste the code into a project, then go to Tools/Macro/Run Macro and run AddElements. You can then use Acrobat to create a standard PDF, and after you are finished, run RemElements to put the project back to the way it was. Like all code you find on the net, please backup your presentation before you start - no warranties are offered or implied!
The code is:
Sub AddElements()
Dim shp As Shape
Dim i As Integer, n As Integer
n = ActivePresentation.Slides.Count
For i = 1 To n
Dim s As Slide
Set s = ActivePresentation.Slides(i)
s.SlideShowTransition.Hidden = msoTrue
Dim max As Integer: max = 0
For Each shp In s.Shapes
If shp.AnimationSettings.Animate = msoTrue Then
If shp.AnimationSettings.AnimationOrder > max Then
max = shp.AnimationSettings.AnimationOrder
End If
End If
Next
Dim k As Integer, s2 As Slide
For k = 0 To max
Set s2 = s.Duplicate(1)
s2.SlideShowTransition.Hidden = msoFalse
s2.MoveTo ActivePresentation.Slides.Count
Dim i2 As Integer
For i2 = s2.Shapes.Count To 1 Step -1
With s2.Shapes(i2)
If .AnimationSettings.Animate = msoTrue Then
If .AnimationSettings.AnimationOrder > k Then
.Delete
Else
.AnimationSettings.Animate = msoFalse
End If
End If
End With
Next
Next
Next
End Sub
Sub RemElements()
Dim i As Integer, n As Integer
Dim s As Slide
n = ActivePresentation.Slides.Count
For i = n To 1 Step -1
Set s = ActivePresentation.Slides(i)
If s.SlideShowTransition.Hidden = msoTrue Then
s.SlideShowTransition.Hidden = msoFalse
Else
s.Delete
End If
Next
End Sub
Enjoy!

21 comments:
Nice hack, Neil!
Just awesome... you made my day :) Thank you so so much
Hi, I'd really like to use your code but ca't figure out where exactly to paste it. Please could you explain it.
Thanks
Anon: Tools, Macros, Visual Basic Editor.
Hi, Your code was a big help converting my powerpoint animations so that it could be viewed on slideshare. Thanks! My only suggestion for improvement is to recognize when multiple animations are supposed to happen at the same time (e.g. one element appears while another disappears). Anyways, I was able to work around this constraint, and your code saved me a lot of time. Thanks again.
btw, I cited this post on
my slideshare (in the description section).
Best, --Erica
Shoot! I'm dumb and just now saw you had a new and updated version up. Anyways, I'll bookmark it and try it next time. Thanks again!
Erica: Glad you liked it. I still have the intention to package this up and put it on my home page - given it's use for others I'll definitely try and do that soon.
I also very much like the idea of slideshare.net, I think I'll have to try and start using that too.
Thanks a ton! That was invaluable -and easy enough to follow even for me!
Geeez! Some great audience you have! Lol. Well,it's always best to come up with activities you and your audience can interact. Thanks for sharing and more power
Very nice code! Is there any easy way to export it for use with OpenOficce (LibreOffice) Impress? It has a similar tool called "libreoffice basic", but when I try to use your code as per instructions it says something like syntax error". Any suggestion would be really appreciated.
Jondas: sorry, I don't have any experience with oo basic, if you make a tweak that does work please post it as a comment here so others can use it.
This is great! I just added it to PowerPoint 2011 on Mac and it works like a charm. Thanks Neil!
I actually needed to do this in multiple presentations, so rather than copying and pasting it into each deck, I just created a separate "PDF generator.pptm" with these macros. Then I open the deck I want to turn into a PDF, and run the macros from the .pptm. Works perfectly.
Neil:
Could you give me the steps on how to do this using PPT 2010? I can't seem to be able to paste into Visual Basic Editor so I'm at a loss. Thanks.
mscanley: Can you download this file? http://community.haskell.org/~ndm/darcs/office/PowerFlat.bas Then if you import that into powerpoint you should be able to run the macro even if you can't edit it.
Neil,
Thanks for this script. You saved me many hours doing this manually.
Great job,
Thanks,
Ryan D
Hello,
Thanks for this tip that is really useful.
Just a drawback: the incrementation of the slides numbers :-( (my final slide is slide # 99/15)
Do you have a trick to avoid this?
Thanks in advance ;-)
Hello,
Thanks for this tip that is really useful.
Just a drawback: the incrementation of the slides numbers :-( (my final slide is slide # 99/15)
Do you have a trick to avoid this?
Thanks in advance ;-)
Hello,
Thanks for this tip that is really useful.
Just a drawback: the incrementation of the slides numbers :-( (my final slide is slide # 99/15)
Do you have a trick to avoid this?
Thanks in advance ;-)
Thanks for this scripts. It helped a lot.
Thanks a lot for this. It helped a lot.
thanks a lot!!!!!!!!!!!!!!!!!
Post a Comment