Many presentations don't require VBA solutions. In fact, you can create presentations and never use VBA at all. Occasionally, however, you run into something PowerPoint can't do on its own. For instance, there's no built-in method for displaying the slide show name on a slide (or all slides). For that, you can use the simple macro that follows:
'Add a text box to display name of slide show.
Dim sld As Slide
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If Left(shp.Name, 6) = "Footer" Then
shp.TextFrame.TextRange.Text = ActivePresentation.FullName
The biggest decision when using this macro isn't the macro but rather, how to call it. Rather than slant you one way or another, I'll use the simplest method-a bit later. For now, take a second to review the macro. The code cycles through all the shapes on each slide in the presentation. When the code encounters a shape that begins with the text "footer," it will display the slide show name in that shape. This route lets you choose which slides to display the name on by simply adding a footer. So, let's do that now:
- Click the Insert tab.
- Click Header & Footer in the Text group.
- In the resulting dialog, click the Footer option and click Apply To All. You can add the footer to individual slides or a group of slides, rather than all-it just depends on your needs.
Once the footers are in place, add the sub procedure as follows:
- Press [Alt]+[F11] to launch the Visual Basic Editor (VBE).
- Click Module on the Insert menu.
- In the resulting module, enter the procedure above.
- Save the presentation as a macro-enabled presentation (.pptm).
At this point, you're ready to run the macro:
- Click the Developer tab.
- Click the Macros option in the Code group.
- In the resulting dialog, select the SlideShowName() macro and click Run.
Every slide with a footer will display the slide show name. There are other ways to execute macros, but this is the simplest. When applying the macro to your own presentations, you might want to use a different trigger. In addition, this macro isn't dynamic. If you change the name of the presentation file, you'll have to remember to rerun the macro.
Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.