PDA

View Full Version : Increase Count on Button click powerpoint 2010



Brightspark9
05-04-2017, 02:20 AM
Hello,

I have a powerpoint presentation.

Slide 1 opens a messagebox asking for a username. The username is transferred to a certificate of completion on slide 19. This works fine.


Sub test()Dim x As String


x = InputBox("Please Enter Your Name", Name)
ActivePresentation.Slides(19).Shapes.Title.TextFrame.TextRange = x


SlideShowWindows(1).View.Next


End Sub

I would like to add a counter which would be displayed on slide 18. The counter would indicate how many correct answers had been selected during the slideshow.
If the required number was not achieved the show would bypass the certificate (slide19) and go directly to (slide20).

I have tried the following without success.

Sub test()Dim x As String
Dim Count As Integer
Count = 0


x = InputBox("Please Enter Your Name", Name)
ActivePresentation.Slides(18).Shapes.Title.TextFrame.TextRange = Count
ActivePresentation.Slides(19).Shapes.Title.TextFrame.TextRange = x


SlideShowWindows(1).View.Next


End Sub

code for correct click


Sub Right()

Count = Count + 1
MsgBox "Correct Answer. Well Done!"


SlideShowWindows(1).View.Next


End Sub



Many Thanks

John Wilson
05-04-2017, 10:56 AM
This should work:


Dim Count As Integer ' note outside of sub

Sub test()


Dim x As String
Count = 0
x = InputBox("Please Enter Your Name", Name)
ActivePresentation.Slides(19).Shapes.Title.TextFrame.TextRange = x
SlideShowWindows(1).View.Next
End Sub


Sub Right()


Count = Count + 1
MsgBox "Correct Answer. Well Done!"
ActivePresentation.Slides(18).Shapes.Title.TextFrame.TextRange = CStr(Count)
SlideShowWindows(1).View.Next
End Sub

There are better ways to do this though Google "Powerful PowerPoint for Educators" my friend David has many examples of this sort of quiz on his site.