Powerful PowerPoint Book Cover
Buy the Book
Examples by Chapter
Examples from Real People
More Tricks
About the Author
Contact the Author
Other Resources
Powerful PowerPoint for Educators:
          Using Visual Basic for Applications to Make PowerPoint Interactive
          by David M. Marcovitz

More Tricks

This space is dedicated to VBA tricks that were not included in the book. The examples here might not be explained as well as those in the book or as fully developed or tested as other examples on this site, but they will show you how to do things beyond what is in the book.

Click on a link below to download an example in the format you choose.

Examples are available in two formats: Zip (.zip) format (widely available on Windows computers but accessible on Mactintosh computers as well) and text format (the VBA code only). These examples are not on this page in Stuffit format because this page is meant to allow me to quickly post examples. If you require Stuffit versions of these files, please let me know. Stuffit Expander (http://www.stuffit.com/) is available for free and for both Macintosh and Windows platforms. It opens both Stuffit files and Zip files. Computers running Windows XP can automatically open Zip files. Earlier versions of Windows require a program, such as Stuffit Expander or WinZip to open Zip files.

Click on a an example to download it. These examples will not run over the Web, they will not run with the PowerPoint Viewer, they will not run while compressed, and they will not run with macros disabled. Be sure your macro security is set to medium or low, and be sure to unzip or unstuff the files before running them.

# Description Zip Version Text Version

The book does not cover writing results to a file. This example writes the quiz results to a file. It is just like the Printable Page example in the text (see Example 7-9), except that the PrintablePage procedure is changed so that in addition to creating a printable slide, the results are also written to a text file. The text file MyTestFile.txt must exist in the same location as the PowerPoint file.


Another example that writes to a file: Ask for a name, address, and city/state/zip. Write that information to an existing file named addressFile.txt


Several people have wanted a printable page that prints without the Print button. This is particularly helpful if you have modified the Printable Page (see Example 7-9), to create a certificate of completion rather than a list of questions answered. This example is exactly like Example 7-9, except that when you print, the buttons do not show up on the printout.


This example allows you to click on a shape to make it bigger. Clicking again will return it to its original size.

Bigger and Smaller.zip
Bigger and Smaller.txt

This is some code to move shapes around on the screen. The first slide has a single shape. Click on the "Move To 5,5" button, and the rectangle will be moved to the top left of the screen (5,5). Click on the "Ask and Move" button, and you will be asked where you want to move. Slide 2 has a small checker board with a couple of checkers. Click on a checker, and it will turn green. Click on any empty square on the board, and the green checker will move there. This isn't that smart and would need a lot more work to create a decent checkers game.


Someone asked me about using HTML code in the text of PowerPoint. He wanted VBA to be able to take simple tags, such as <B> and <I>, to convert text to bold and italic. This example does that.


My daughter is older now, and the "Ella Can Read" example (see Examples 8.16 and 8.17 are too simple for her even with some fun additions such as many longer questions with harder words and a way for her to choose only the hard questions. This is my crazy idea of an answer (yes, she reads books, and we limit her time on the computer as well). This example creates a branching story that randomly branches. The VBA simply looks for numbers in shape 2 on the current slide and randomly picks which slide number to jump to. If there is only one choice, it jumps to that slide. If there are no choices, it says "The End" and quits. While this could all be done in PowerPoint, I found it easier to do in Word, so the Word file is my story (it's fairly silly and needs more work). It uses the style Heading 1 for the text followed by Heading 2 for the choices. This is easily loaded into PowerPoint by choosing Slides From File from the Insert menu. The template (MakeStory.pot) has the VBA built-in, so write the story, open the template, delete the first blank slide if your version of PowerPoint creates it, and insert the slides from the Word file. Writing a coherent branching story is definitely the hard part.


Here are a couple of ideas for Drag and Drop, including a link to information about a new program from Hans Hofler, the original Drag and Drop creatore



Can you make a crossword puzzle with PowerPoint and VBA? Someone named Mel asked me this so I made this sample as a proof of concept. It really contains no new VBA tricks, but it combines them for an interesting effect.


Several people have asked about making a hover button (you know the buttons that change when you hover over them on the Web). It might be easier to do without VBA, but here is a VBA solution.


Many examples in the book involve hiding and showing shapes. The problem is that while you are developing a presentation, shapes tend to be hidden before the procedure that shows them works. This presentation includes a simple procedure to show every shape in a presentation. Copy the ShowItAll procedure and run it any time you need to get all your hidden shapes back.


While this occasionally happens on any computer, it happens more frequently on a Mac in PowerPoint 2004: you make a link to a file and then move the presentation and the link breaks. Most of the time, this is your fault. If you want the link to persist, the file has to be in the same folder as the PowerPoint presentation, and when the presentation gets moved, the linked file has to move as well. For more information about this, read this entry from the PPT FAQ: http://www.pptfaq.com/FAQ00155.htm. However, sometimes, this is not your fault. You have done everything right, and the link still breaks. I have seen this frequently on Macs. What happens is that PowerPoint inserts the link with the full path to the file. If you move the file, the path changes, but it doesn't change in PowerPoint. In Windows, you can use the FixLinks add-in to fix problem, but it doesn't work on a Mac (at least for version 2004). This quick and dirty code will let you create relative links. It does not error checking, and you have to type the name of the file, but it works. The code works just like Example 8.7. It works in Normal View, not Slide Show view. You have to select an object or some text and then use Alt-F8 to run one of the macros. One macro will create a link from an object (i.e., if the thing you want to click on is a button or shape). The other will create a hypertext link (if the thing you want to click on is text).


I have gotten a couple of questions about random flashcards so I have made a simple example. The zip file is done in PowerPoint 2007, but is should work in any version. However, if you just want code, copy it into your module from the text file. You will need a first slide with a button that is tied to RandomNext, a last slide with whatever you want on it, and pairs of slides in the between (the random code will break if there is anything else or if the first and last slides are missing). For each pair of slides, the first one needs a button to go to the next slide, and the second one needs a button linked to RandomNext. It will go through the pairs of slides in random order until it has gone through them all, and then it will jump to the last slide. You can have as many pairs of slides (each one representing a flash card) as you like. One day, I'll get ambitious and rewrite the random code to use a more sophisticated flashcard algorithm (like Corrective Feedback Paradigm by Marty Siegel), but that is too much effort for now.


Someone wanted a simple mechanism for keeping score by simply clicking on buttons to add an amount to a score text box. This doesn't use anything that isn't described in the book, but it is a neat application. Also, note that with a minor modification, the code can be adjusted to have the score text box be on a different slide than the current slide (see the section This Slide or Another Slide in the book). This example was created in 2010, but it should work in any version. On a Mac, it would probably need a call to refresh the slide (see "Refreshing after Hiding and Showing in Mac PowerPoint 2004" in the Errata section on this Web site).


This page was created by Dr. David M. Marcovitz.
Last updated: April 6, 2011