GENERATE CERTIFICATE WITH NAME INTERACTIVE POWERPOINT QUIZ

Students can play the PowerPoint Quiz Game and receive a certificate if they score a minimum percentage in the report card which is automatically generated in PowerPoint by Visual Basic Applications (VBA Coding).

The PPT Quiz Game will now also generate a certifcate automatically with the Student’s name and another placeholder (which is kept as Location in my PPT Quiz Game Tutorial).

The certificate is saved as .PDF file in the location which the student chooses. You can also customise the codes such that the certificate is saved in a fixed path.

This PPT Quiz Game Certificate allows a proof to exist that the quiz was answered with sufficient accuracy as I have introduced an option that the Certificate should only get printed if they secure at least 50 percentage in the Quiz

I HIGHLY SUGGEST WATCHING THE VIDEO IN ITS ENTIRETY.
IT INTRODUCES YOU TO VARIOUS ASPECTS OF VISUAL BASIC CODING FOR POWERPOINT

The earlier VBA Macro Codes for the PowerPoint Interactive Quiz Game is within their respective webpages. Scroll down to choose get the codes of the specific module.

Download Premium Interactive PowerPoint Quiz Game TEMPLATE

Send Report Card to Google Sheets, Import Questions from Excel.
Make your quiz game in 54 seconds!

Insert student's name in PPT Quiz Game Certificate

Using the Syntax Label1.Caption we can increase or decrease the Points. We need not have a separate data integer which scores the point. This is very straight-forward and easy for people to customise and understand the code.

'Slide Number 2 (Slide11) - Proceed Command Button'

Private Sub CommandButton1_Click()

'Set CertificateSlide'
Set CertificateSlide = ActivePresentation.Designs(2).SlideMaster.CustomLayouts(2)

'Change Text within Certificate Slide TextBox to the Input Value'
CertificateSlide.Shapes("CName").TextFrame.TextRange = TBName.Value
CertificateSlide.Shapes("CLocation").TextFrame.TextRange = TBLocation.Value

'Goto Next Slide'
ActivePresentation.SlideShowWindow.View.Next
End Sub 

Print/Export Certificate in PPT Quiz Game using VBA Macros in .PDF format

We can now export the certificate in .PDF Format using the .ExportAsFixedFormat in Visual Basic Applications.

I have added an If-Condition which requires a minimum of 50% to print the certificate. You can customise that to fit the needs of your classroom or organisation.

'Slide Number 10 (Slide8) - Print Certificate Command Button'

Private Sub CommandButton1_Click()

Set CertificateSlide = ActivePresentation.Designs(2).SlideMaster.CustomLayouts(2)
CertificateSlide.Shapes("CPercentages").TextFrame.TextRange = Round(SlideLayout24.Percentages.Caption, 1)

If (SlideLayout24.Percentages.Caption) > 50 Then

'Print the certificate'

'1. Choosing the location:'
Application.FileDialog(msoFileDialogFolderPicker).Show
Dim Location As String
Location = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"

'2. Declaring the slides which are to be printed'
Set SlidesToBePrinted = ActivePresentation.PrintOptions.Ranges.Add(10, 11)

'3. Exporting it as a .pdf file'
ActivePresentation.ExportAsFixedFormat Location & Slide11.TBName.Value & " Quiz Game Certificate" & ".PDF", ppFixedFormatTypePDF, , , , , , SlidesToBePrinted, ppPrintSlideRange

'4. Return to Slide Show Mode'

Output = MsgBox("PDF has been generated", vbInformation, "Certificate has been printed")
ActivePresentation.Windows(1).WindowState = ppWindowMinimized 'Remove this life if you are saving it .ppsm format'

Else

Output = MsgBox("Your percentage is less than 50. Certificate cannot be printed", vbCritical, "Secure above 50 percentage")
End If

End Sub 

In the Step 3 of the following code, I am saving the .PDF in Location – which is chosen by the student. If you do not want that and rather want to set the location by yourself, you can refer to the following VBA Macro Code which saves the PPT Quiz Game Certificate in Desktop:

'3. Exporting it as a .pdf file in Desktop'
ActivePresentation.ExportAsFixedFormat "C:\Users\Bhavesh Shaha\Desktop\" & Slide11.TBName.Value & " Quiz Game Certificate" & ".PDF", ppFixedFormatTypePDF, , , , , , SlidesToBePrinted, ppPrintSlideRange 

If you want to generate the UserName of your computer automatically, you can use the following syntax: in my case, the output would be Bhavesh Shaha.

Environ("Username") '=Bhavesh Shaha' 

Removing Decimals / Rounding off Percentage Value in PowerPoint Macros

Round(66.6666,0) '=67'
Round(66.6666,1) '=66.7'
Round(66.6666,2) '=66.67'

'Round off % in the Label by the following:'
Round(SlideLayout24.Percentages.Caption, 1) 

It becomes a pain when the certificate prints 66.66666% so we use the Round function to remove all the decimals of the Percentages.Caption (Student’s Percentage secured in the PPT Quiz Game) or round it off to the nearest decimal which can be set within the brackets of the Round function in VBA Macros.

Saving as PowerPoint Show (to open directly in Slide Show Mode)

ActivePresentation.Windows(1).WindowState = ppWindowMinimized 'Remove this life if you are saving it .ppsm format' 

We can save the PowerPoint Interactive Quiz Game which can generate a certificate in .PPSM format so that it opens directly in Slide Show Mode. While doing this, remember to delete the above line of code from the PrintCertificate Sub-Routine which is within Slide10.CommandButton1

Slide Name vs
Slide Number in PPT VBA

This is a personal pet peeve of mine and it is very confusing for beginners of PPT VBA scripting. 

We need to understand that the slide number 3 (say) will not always be named Slide3.

The slides are named chronologically on the basis of its creation.

If you have 100 slides, and you decide to insert a new slide in your powerpoint presentation, the latest slide will be named Slide101 and you can insert Slide101 between the 5th and 6th slide and it will still be named Slide101 even though it is slide number 6.

Also, when we clear the values of the TBName and TBLocation ActiveX Textboxes, we need to mention where those 2 TextBoxes are present since the code in not within the Slide in which they both ActiveX Textboxes reside:

Slide11.TBName.Value = ""
Slide11.TBLocation.Value = "" 

How to print multiple non-consecutive slides in exporting PowerPoint Quiz Game Certificate?

I want to save slides 1 to 10 and also 12 but not 11. What code do I need in such case?

'2. Declaring the slides which are to be printed'
ActivePresentation.Slides.Range(Array(1, 3, 5)).Select

'3. Exporting it as a .pdf file'
ActivePresentation.ExportAsFixedFormat _
Path:=Location & Slide11.TBName.Value & " Quiz Game Certificate" & ".PDF", _
FixedFormatType:=ppFixedFormatTypePDF, _
RangeType:=ppPrintSelection 

Instead of exporting PrintRange as shown in my earlier codes, we can select the PowerPoint slides manually within a SlideRange and export that. You will also need to change ppSlideRange in .ExportAsFixedFormat to ppPrintSelection.’

Change the values within the .Range(Array(1,3,5)) to the slides which you want to print. In this case, slide 1, 3 and 5 are selected to be exported.