Powerful PowerPoint Book Cover
Home
Buy the Book
Examples by Chapter
Examples from Real People
More Tricks
Errata
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

Errata

As I discover errors, updates, and clarifications, I will list them here.

  • Page 81
    The printer left out the "not equal" symbol in the AddPlants and AddAnimals procedures. The fifth line (beginning with If) of each procedure should read
    If newStuff <> "" Then
    See Example 6-7 for the complete correct example.
  • Pages 81-82
    This is not an error but a note. In PowerPoint 2003, if you create a text box, but do not add any text to it, the text box will disappear. This can be problematic for the Signs of Spring example. You must have something in your text boxes after you create them. If you set up your slide just like the picture on page 82, you can have the first line of the text box be a blank line. Even a blank line will fool PowerPoint into keeping the text box around.
  • Page 128
    The MakeNotDirty procedure is incorrect. It should read:
    Sub MakeNotDirty ()
    ActivePresentation.Saved = True
    End Sub
    See Example 8-6 for the complete correct example.
  • Pages 139-142
    The Printable Page example is not incorrect; however, if you use the RightAnswer and WrongAnswer procedures on page 136 (as suggested), you will need to add
    ActivePresentation.SlideShowWindow.View.Next
    at the end of the RightAnswer and WrongAnswer procedures. Otherwise, only the last answer chosen will be printed with the results (although scoring will be correct). See Example 8-11. Alternatively, adjust the code for RightAnswerButton and WrongAnswerButton as shown in Example 8-12, where only the first answer is recorded for the results slide.
  • PowerPoint 2007 Hiding and Showing
    Hiding and showing does not always work properly in PowerPoint 2007. You can see this error if you have code to show a shape and it doesn't show, but when you quit out of Slide Show view, the shape is there. In this case, you can use an alternative method to hide and show shapes. Instead of hiding and showing the shapes, you can move them off the viewable area of the slide and move them back again. For example, in Example 6.6, you can "hide" the shapes with this Initialize procedure:
    Sub Initialize()
    ActivePresentation.Slides(2).Shapes(4).Top = 3000
    ActivePresentation.Slides(3).Shapes(4).Top = 3000
    End Sub

    Showing the shapes is a bit trickier because you have to put the shape back in the right place. You can guess and adjust with something like this for the RightAnswer Procedure:
    Sub RightAnswer()
    ActivePresentation.SlideShowWindow.View.Slide.Shapes(4) _
    .TextFrame.TextRange.Text = "Good job, " & userName
    ActivePresentation.SlideShowWindow.View.Slide.Shapes(4).Top = 150
    End Sub

    And then adjust the number 150 until it is in the right place. If you have a lot of shapes that need this adjustment, you might use a little macro to find out where the shape is now:
    Sub WhereAmI()
    MsgBox ActiveWindow.Selection.ShapeRange.Top
    End Sub

    You must be in Normal/Edit View to run this code and have the shape you want selected. Then hit Alt-F8 and choose WhereAmI macro. The message box that pops up will have the right number to use instead of 150. See Example 8-11. Alternatively, adjust the code for RightAnswerButton and WrongAnswerButton as shown in Example 8-12, where only the first answer is recorded for the results slide.

  • PowerPoint 2007 Hiding and Showing Revisited
    Some people have experienced problems hiding and showing shapes in PowerPoint 2007. The symptom is that you use the .Visible property to hide a shape (e.g., ActivePresenation.Slides(2).Shapes(3).Visible = False), and the shape doesn't go away until you leave Slide Show view (not very helpful as you run your slide show. This mainly happens in PowerPoint 2007. An alternative is to move the shape off the viewable area of the slide (to hide it) and back onto it (to show it). You can do this by adjusting the .Top of the shape:

         ActivePresenation.Slides(2).Shapes(3).Top = -2000
    This moves the top of the shape above the slide. To show it, do the same thing, but set the .Top back to what it was. The problem with this is getting the code exactly right, including getting the shape back where it was. No problem. Copy and paste the following code to your module:

    Sub HideAndShow2007()
    Dim oShp As Shape
    Dim hide As String
    Dim show As String

    Set oShp = ActiveWindow.Selection.ShapeRange(1)

    hide = "ActivePresentation.Slides(" _
    & ActiveWindow.Selection.SlideRange(1).SlideIndex _
    & ").Shapes(" & Chr$(34) & oShp.Name & Chr$(34) & ").Top = " _
    & -oShp.Height - 100

    show = "ActivePresentation.Slides(" _
    & ActiveWindow.Selection.SlideRange(1).SlideIndex _
    & ").Shapes(" & Chr$(34) & oShp.Name & Chr$(34) & ").Top = " _
    & oShp.Top

    MsgBox "Code to hide: " & hide & Chr$(13) & "Code to show: " & show _
    & Chr$(13) & Chr$(13) & _
    "Open the Immediate Window in the VBA editor to find code to copy and paste"
    Debug.Print "Code to hide: " & hide & Chr$(13) & "Code to show: " & show
    End Sub
    Use this just like Example 8-7 (the code for naming shapes). Once you have a shape in place that you want to hide and show, select that shape, and run the macro HideAndShow2007. This will generate code for you to use in two ways. It will pop the code up in a message box, and it will put the code in the Immediate Window of the VBA Editor (from where you can copy and paste it). To see the code, go to the VBA Editor and choose Immediate Window from the View menu. Just note that if you move the shape later, the code to show will have the wrong location so you might want to run the macro again.

  • Refreshing after Hiding and Showing in Mac PowerPoint 2004
    Sometimes in PowerPoint 2004, Hiding and Showing objects doesn't work. That is, you make an object visible by setting .Visible = True, and the object doesn't show up until you leave the slide and come back to it (unlike the bug in PowerPoint 2007, you don't actually have to leave the show, just the slide where the object was being shown. I have had very good success working around this bug by adding the following code whenever an object on the current slide is being made visible or invisible. After the line of code that includes .Visible = True or .Visible = False, add:
    ActivePresentation.SlideShowWindow.View.GotoSlide _
    ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

    This simply goes to the current slide. It shouldn't really do anything, but it serves the purpose of refreshing the screen. It can work almost any time an action doesn't work until you leave and return to the slide (e.g., it might happen if you change the color of an object or move an object). Just add the refresh code. It won't hurt, and it will often help.

  • PrintablePage Buttons Don't Work in Mac PowerPoint 2004
    Some people have found that the buttons on the PrintablePage (Example 7-9) do not work, or do not work after the first two seconds. You can tell that you have done everything correctly if the printable slide shows up correctly and you can get the buttons to work by exiting the show and then starting the show again. The only work-around I have found for this is to add an extra slide at the end of the show. When the button is pressed to create the printable slide, it will create it after this extra slide. On the extra slide, put a button (put some text in it like "See your results for printing"). Tie this button to the following macro:
    Sub GotoPrintableSlide
    ActivePresentation.SlideShowWindow.View.GotoSlide printableSlideNum
    End Sub
    This assumes you used the code to set the value of printableSlideNum. If you didn't ActivePresentation.SlideShowWindow.View.Next might also work. For some reason, you must have a button click that activates code to go to the next slide to work around this. It is clearly a bug in PowerPoint 2004, and I don't know why this work-around works, but it does.

This page was created by Dr. David M. Marcovitz.
Last updated: July 28, 2010