PowerPoint FAQ
Word FAQ
Home Corporate Services FAQ Word Templates Training Nuclear Training Testimonials Contact Us

PowerPoint FAQ: Keeping Score in PowerPoint

Basically, the process consists of a couple of steps:

1. You need to have specific names for objects on your slides so you can access those objects via code and tell them what their text value is. One of our other MVPs (Shyam) has all sorts of excellent VBA samples and add-ins that will help you when you are ready to delve into VBA. The site link is: http://www.mvps.org/skp/index.html.

The code for naming shapes is:

Sub NameShape()

Dim Name$
On Error GoTo AbortNameShape


If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name


Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)


If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub


AbortNameShape:
MsgBox Err.Description


End Sub

2. The next thing is to create variables for the desired values you want to maintain. If you have three players, the variables might be:

Dim intScore1 As Integer Dim intScore2 As Integer Dim intScore3 As Integer

3. The next thing is to have a macro that adds a value to the desired variable. This basically takes the existing score and adds the desired amount to it. Something like:

Sub Player1Correct100()

intScore1 = intScore1 + 100

End Sub

4. The next thing is to take that value and make it the "text" of an object on your slide. For example I put a rectangle inside the podium for a given player on Slide 3, run the nameshape macro and call the shape "Player1Score". I then tell the text range of that object to be intScore1. For example:

ActivePresentation.Slides(3).Shapes("Player1Score").TextFrame.TextRange.Text = intScore1

5. I then put a line of code to take you back to a particular slide (if desired). In my Jeopardy sample, I also hide the number object on the board (set the visible property to FALSE). So, putting all that together, something like this:

Dim intScore1 As Integer

Sub Player1Correct100()

 
intScore1 = intScore1 + 100
ActivePresentation.Slides(3).Shapes("Player1Score").TextFrame.TextRange.Text = intScore1
ActivePresentation.Slides(4).Shapes("1-100").Visible = False
ActivePresentation.SlideShowWindow.View.GotoSlide (3)

End Sub

6. Last and most important, is to set the Action Settings of your buttons to run the desired macro. You may have three buttons (Correct, Incorrect, Bank) that add a value to intScore1 or even set intScore1 to zero (intScore = 0).

If you want to check out my Jeopardy sample, go to our downloads link and download a copy

GOOD LUCK! Holler back if you need assistance.


Bill Foley, Microsoft MVP (PowerPoint)