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
|
| 1 |
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.
|
filetest.zip (17KB) |
filetest.txt (6KB) |
| 2 |
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
|
fileAddresses.zip (7KB) |
fileAddresses.txt (1KB) |
| 3 |
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.
|
PrintCertificate.zip (17KB) |
PrintCertificate.txt (6KB) |
| 4 |
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 (8KB) |
Bigger and Smaller.txt (1KB) |
| 5 |
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.
|
MovingExample.zip (11KB) |
MovingExample.txt (2KB) |
| 6 |
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.
|
HTMLize.zip (10KB) |
HTMLize.txt (3KB) |
| 7 |
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.
|
MakeStory.zip (53KB) |
MakeStory.txt (1KB) |
| 8 |
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
|
http://www.deadgekko.co.uk/downloads.htm
http://tinyurl.com/bdpopa |
| 9 |
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.
|
Crossword.zip (15KB) |
Crossword.txt (4KB) |
| 10 |
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.
|
HoverButton.zip (15KB) |
HoverButton.txt (5KB) |
| 11 |
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.
|
ShowAll.zip (9KB) |
ShowAll.txt (1KB) |
This page was created by Dr. David M. Marcovitz.
Last updated: February 15, 2009
|