PowerPoint Tips Blog

Helping you with presenting, PowerPoint, and speaking

  • Home
  • Blog
  • Tips
  • E-Store
  • Training
  • About
  • Affiliates
  • Advertise
  • Contact
  • Bblog
Home » Easily create a quiz in PowerPoint using Visual Basic for Applications

Easily create a quiz in PowerPoint using Visual Basic for Applications

April 11, 2001 by Ellen Finkelstein 51 Comments

READ LATER - DOWNLOAD THIS POST AS PDF >> CLICK HERE <<

Did you know it’s possible to create your own quiz slides in Microsoft PowerPoint using its macro functions and doing a little programming in Visual Basic for Applications (VBA)?

You can use quiz slides to make presentations more engaging and fun. They work something like this: Each slide asks a question and displays answer choices. Quiz-takers  then click on the answer they think is correct. If they answer correctly, a Congratulations message appears and they automatically move on to the next slide. If they choose a wrong answer, they receive a “try again” message. The slideshow will not advance until they select the correct answer.

You may think that working with VBA is too complicated, but it’s easier than you might think. This VBA code is easy to understand and, for this tip I was able to use Visual Basic to create a 10-slide quiz in less than an hour.

Step 1: Create multiple-choice slides

The first step is to create the question slides. In PowerPoint, start a new slide using the Title Only slide layout. Type the first question in the title placeholder.

To add the multiple-choice answers, go to the Draw toolbar and choose AutoShapes> Action Buttons. (2007: Home tab> Drawing group> Shapes> Action Buttons section) Then choose the blank action button. Now click on the slide and the new button will appear. When the Action Settings dialog box appears, choose Cancel. You’ll return to this box later in the tutorial.

Resize and position the button on the slide. For consistency, size the button to allow for the longest text answer. Format the button as desired.

answer buttons

Right-click on the button, choose Add Text from the shortcut menu, and type the first answer. Now select the button, copy it to the Clipboard, and paste  additional copies of the button graphic for the remaining answers you’ll need on the slide.

When all the buttons are in place, select each individually and edit its text. You can also align and distribute the answer buttons on the slide. Select them all. Choose Draw toolbar> Align or Distribute, Align Left, then Draw toolbar> Align or Distribute> Distribute Vertically. (In PowerPoint 2007: Drawing Tools Format tab> Arrange group> Align button> Align Left, then Align button>Distrubte Vertically)

Repeat this process to create each additional question slide.

Tip: Within the Slide Sorter view, you can COPY (CTRL+C) the first question slide and PASTE it as many times as needed to quickly create the remaining question slides. Then return to Normal view to edit each slide’s text.

On your final quiz slide, create an action button with the word End, and place it on the slide.

Step 2: Create macros

When the Q & A slides are done, you’re ready to create the macros using PowerPoint’s Visual Basic Editor. Before you begin, make sure that only the presentation you are currently working on is open.

To open the Visual Basic Editor, choose Tools> Macro> Visual Basic Editor.

In 2007 and later, you first need to display the Developer tab if it isn’t already displayed. (By default, it is not displayed.)Choose Office button> PowerPoint Options. In PowerPoint 2007, in the Popular category, check the Show Developer Tab in the Ribbon check box. In PowerPoint 2010 and 2013, go instead to the Customize Ribbon category. On the right side of the dialog box, check the Developer check box.

Then, to open the Visual Basic Editor, choose Developer tab> Code group> Visual Basic.

The editor opens in a new window. The right side of the window will be gray. From the insert menu choose module and you’ll see a blank white area where you can type a macro. We’ll create three macros.

We’ll start with the code for the wrong answer. In the big blank space on the right, type the following on three lines:

Sub Wrong()

MsgBox (“Sorry, that’s not right. Please try again.”)

End Sub

In certain situations, if you make a mistake, the editor will warn you, but the message may not be clear to you. Most often the mistake is a result of mistyping the code. You may have left out one of the quotation marks or the closing parenthesis at the end of a line. Double-check your typing and make adjustments until the Editor shows no warnings.

Next is the code for the right answer. At the end of the line reading “End Sub,” press Enter. This begins a new code group. Then type the following four lines:

Sub Right()

MsgBox (“That’s right!”)

SlideShowWindows(1).View.Next

End Sub

This code is similar to the previous macro, except for the third line, which advances the quiz-taker to the next slide.

On the final slide, you don’t want the slideshow to advance to the next slide because that starts the presentation all over again. Instead, you want viewers to use a button that exits the slideshow. So after the previous “End Sub,” press Enter again and type your final piece of code:

Sub RightLast()

MsgBox (“Congratulations!”)

End Sub

macro to exit to exit the slideshow

Step 3: Attach macros to buttons

To return to PowerPoint from the Visual Basic Editor, click the View Microsoft PowerPoint icon (upper left-hand corner, under the File menu link). Leave the Visual Basic Editor open in the background. In PowerPoint, save the presentation, as this saves the new macros as well.

Go to your first question slide and select the button with the correct answer. Note: Select the entire button, not just the text on the button. You do this by clicking on the border around the edge of the button.

Right-click the button and choose Action Settings from the shortcut menu. The Action Settings dialog box appears. Choose the Mouse Click tab, and in the Action on Click section, check the Run Macro option and select your new Right macro from the drop-down list. (Notice that all the macros on this list are named for the three pieces of code you created in the Visual Basic Editor.) Click OK. (Note: Thanks for one of the commenters below for pointing out that you may have to choose Hyperlink instead of Action Settings.)

Now select each of the wrong answers and follow the same procedure, except select the Wrong macro from the drop-down list.

Before going on to the other slides to assign the proper macros, try out the buttons on the first slide. Go into Slide Show view. Click on a wrong answer. A text-message box should pop up indicating you have chosen the wrong answer. Click OK to close the box. Check the other wrong answers on the slide to make sure they also work. Finally, select the correct answer. This time, the text-message box should indicate you have chosen the right answer. Click OK and the slideshow will automatically advance to the next slide.

With the first slide working properly, edit the rest of the presentation, attaching the appropriate macros to the buttons. On the last slide, assign the RightLast macro to the correct answer  so that quiz-takers stay on the last slide.

Remember the End button you created on this final slide? Right-click on that button and choose Action Settings. In the Action Settings dialog box, choose the Hyperlink To option and choose End Show from the drop-down list. Click OK. Quiz-takers can use this button when they’re finished answering all the questions.

Be sure to save the PowerPoint file.

Step 4: The final setup

To prevent the quiz-takers from clicking through without answering all the questions, choose Slide Show> Set Up Show. In the Set Up Show dialog box choose the Browsed at a Kiosk (Full Screen)” option under the Show Type area. Click OK. With this setting, the only way someone can get out of the presentation is to use the ESC key.

final setup

final setup

Now, go into Slide Show mode and try your quiz, making sure all wrong answers and right answers use the proper macro. If you get a message about macros, you’ll need to tell PowerPoint that you want to run the macros. This is due to PowerPoint’s security settings.

That wasn’t so difficult, was it?

The concept here is from David M. Marcovitz’s book, Powerful PowerPoint for Educators.

0 0 votes
Article Rating
Share
Tweet
Share
0 Shares
READ LATER - DOWNLOAD THIS POST AS PDF >> CLICK HERE <<

Related posts:

  1. Create a quiz in PowerPoint
  2. Create a quiz game
  3. Create a visual menu
  4. Create a Visual Summary Slide

Filed Under: Content Tagged With: PowerPoint, presentations, slides

Subscribe
Notify of
guest
guest
51 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
nicole ann a gonzaga
nicole ann a gonzaga
14 years ago

thanks for the codes !! :))

0
Daniel Coleman
Daniel Coleman
14 years ago

Hello there,

When I run my presentation, I can not seem to get this to work. I click on the options and the do not run to the next slide or come up wrong. It stays on the same slide and when I click on a box a dotted line appears around it!

any help?

Ta
Daniel

0
Ellen
Ellen
14 years ago
Reply to  Daniel Coleman

That is usually because of PowerPoint’s security settings. I’d need to know which version of PowerPoint you have to show you how to change them. But start with Tools>Options or File/Application Button>Options.

0
Rick Owens
Rick Owens
14 years ago

I have created a quiz integer add and subtract macros button….that was eay. But when I use my required action button to run my Macros, such as a progressive score button, the Macros window “pops-up” within that slide and is much smaller than the slide itself. It works just fine but is there a way to for the button to make this score open in it’s own slide to keep score? In other words, can I make that pop-up window an actual slide? Thanks for your input please.

R. Owens

0
Ellen
Ellen
14 years ago
Reply to  Rick Owens

I’m not sure I understand and I’m not a programmer, but you can programmatically create a new slide and display the results of calculations there. In my book PowerPoint for Teachers I have a chapter on creating a quiz with VBA using code from David Marcovitz. It displays the score on a list slide that the code creates on the fly. At http://www.loyola.edu/edudept/powerfulpowerpoint/, you can look at some of his code. He lists it by chapter and I don’t know which chapter would have the code you need. If you’re creating more complex quizzes, I recommend that you buy his… Read more »

0
golfcents
golfcents
14 years ago

Hi isnt
SlideShowWindows(1).View.Next supposed to be SlideShowWindow(1).View.Next no s after window???

either way I get syntax error but this almost works
ActivePresentation.SlideShowWindow(1).View.Next

2003 PPT

actually all I want is a text box to hold a value (a score) and have a button add 1 to the value in the text box…

can you assist – you can answer at my email – and if it works feel free to add to this post

0
Ellen
Ellen
14 years ago
Reply to  golfcents

Try it like this: ActivePresntation.SlideShowWindow.View.Next
For more information than that, you’d need to ask a programmer, which I am not. Go to the PowerPoint Discussion Group at http://answers.microsoft.com/en-us/office/forum/powerpoint?tab=all and ask the question there. A few programmers frequent the forum.

0
Adam
Adam
14 years ago

Great work. The problem I have is when people take the test and they know programming they can right click on the buttons and look at the hyperlink to discover the correct answer. How do I fix that?

0
Rose Pierce
Rose Pierce
14 years ago

Hello, thank you for the info- I have set up several quizzes with your instructions. I know I can easily assign a sound to an action box. How do I asign a sound to the VBS message box? Right now, every time the message boxes appear, the “error” sound is there. I would like to keep it for the wrong answers, but have an “applause” sound for the right answers. Thanks!

0
Ellen
Ellen
14 years ago
Reply to  Rose Pierce

Rose,
My VBA skills are pretty limited, so I don’t know how to add a sound in VBA. The error sound might be, well, an error in the code. You might try a non-VBA technique for creating the quiz, but I only have that written out in my ebook, 101 Advanced Techniques Every PowerPoint User Should Know.. You can see a demo at http://www.ellenfinkelstein.com/pptblog/create-a-quiz-in-powerpointdemo-of-technique-7-from-my-e-book/.
Ellen

0
Sammer
Sammer
14 years ago

Hi there,

for some reason when i right click my action button, i dont get the action settings, how do i get the action settings?
Thanks

0
Clint
Clint
13 years ago

Hello Ellen,

How can I get my Powerpoint quiz to self grade? I would like for my students to print and send me their results.

Thanks.

0
Ellen
Ellen
13 years ago
Reply to  Clint

Clint,
I have instructions in my book, PowerPoint for Teachers. You can find it on Amazon. It’s too much to put in a blog post–the instructions take up a whole chapter of the book!

0
Dilip Singh
Dilip Singh
13 years ago

I want to Visul Basis coding any quiz contest.

0
Ellen
Ellen
13 years ago
Reply to  Dilip Singh

In addition to the code on this page, I have a whole chapter in my book, PowerPoint for Teachers. You can buy it from Amazon.com at this link: http://www.amazon.com/gp/product/078799717X?ie=UTF8&tag=ellenfinkelstein&linkCode=as2&camp=1789&creative=9325&creativeASIN=078799717X

0
Hashim Elhadi
Hashim Elhadi
13 years ago

Hello Ellen
Thank you for I see as great work which will be my first step in the world of VBA. I’ll always remember this tutorial.
For some reason the (right) does not make the slides advance, it shows the message and remains at the same slide

0
Ellen
Ellen
13 years ago
Reply to  Hashim Elhadi

It could take quite a while to troubleshoot and I’m not a serious VBA programmer. I suggest that you go to Microsoft’s discussion group and there are VBA programmers there who will help you.
http://answers.microsoft.com/en-us/office/forum/powerpoint?tab=all

Good luck!

0
beatrice
beatrice
13 years ago

Sammer wrote “for some reason when i right click my action button, i dont get the action settings, how do i get the action settings?”

That’s becuase Ellen got it WRONG !!! In PowerPoint 2007 you don’t get “Action Settings” on right-click, you get “Hyperlink”, and from there you can progress.

0
Ashu khan
Ashu khan
13 years ago

Hi Ellen i want a visual basic codes for making quiz.Its very important for me so please i am requesting u to give me a visual basic codes for making quiz

0
Ellen
Ellen
13 years ago
Reply to  Ashu khan

Ashu, My book, PowerPoint for Teachers, has a entire chapter on this topic.
Check it out at http://www.amazon.com/gp/product/078799717X?ie=UTF8&tag=ellenfinkelstein&linkCode=as2&camp=1789&creative=9325&creativeASIN=078799717X

0
Kris Mac
Kris Mac
13 years ago

I am trying to make a powerpoint presentation were the users will need to enter an answer in the text box but make it so it will only allow to the next screen when the correct text has been entered and or flash up if incorrect, i dont know if this is possible as i am quite new to making presentations. Any ideas would be a great help.

Thanks

0
Ellen
Ellen
13 years ago
Reply to  Kris Mac

That’s how the quiz in this tip works. You can do it without VBA coding as well. It’s one of the techniques in my ebook, 101 Advanced Techniques Every PowerPoint User Should Know (http://www.ellenfinkelstein.com/estore/101advancedtechniques.html) and also in PowerPoint for Teachers (http://www.amazon.com/gp/product/078799717X?ie=UTF8&tag=ellenfinkelstein&linkCode=as2&camp=1789&creative=9325&creativeASIN=078799717X)

0
Martin Bush
Martin Bush
13 years ago

Hi Ellen, you might like to know that you can now create an online multiple-choice “answer until correct” quiz, or alternatively a timed exam, simply by uploading a PowerPoint document with one question per slide to QuizSlides.com. (Disclosure: I’m the founder!)

0
dr ravish
dr ravish
13 years ago

hi ma’m thanks for the guidance..really appreciate clarity of explaining about ppt quiz. really awesome

0
mhelia
mhelia
13 years ago

im doing a quiz program using vba.. and i find it so hard .. tnx for the tips anyway :)) Godbless

0
Prasad
Prasad
13 years ago

i was not getting actually the result, when i was clicked it just blink & no popup had displayed 🙁 please rply me @ my mail or here .. i m in needy position yar..

0
Mengheng LIM
Mengheng LIM
12 years ago

Thanks, Just a reminder for the new user, please make sure that you save the file as the pptm(it means enable macro)

0
Lissa Bell
Lissa Bell
12 years ago

I have PPT 2008 which apparently does not accept macros. Is there a workdaround?

0
Ellen Finkelstein
Ellen Finkelstein
12 years ago
Reply to  Lissa Bell

PowerPoint 2011 brought back support for macros, so I would upgrade.

0
BELAID
BELAID
12 years ago

Good afternoon,
Thanks very much, Ellen, for all these topics.I have learned a lot with your interesting blog.Can i ask you for tutorials about drawing technique’s with powerpoint 2007.

Abder

0
fabry
fabry
12 years ago

Hello, if in a quiz, I wanted to keep track of the correct answers as I do?

0
Ellen Finkelstein
Ellen Finkelstein
12 years ago
Reply to  fabry

To create a quiz that keeps track of correct answers, you need some more VBA. I have a chapter in my book PowerPoint for Teachers that covers this topic. (You can buy it on Amazon.com here.) For more information, I recommend David Marcovitz’ book, Powerful PowerPoint for Educators, which is all about using VBA to create quizzes. You can buy that here. It’s an expensive book because it’s considered a textbook.

0
Lisa
Lisa
11 years ago

Is it possible rather than having just the “Incorrect answer” response but a Incorrect with an explanation for why it is wrong? So you would need individual wrong pop ups?

0
Nana Yaw
Nana Yaw
11 years ago

Thank you and can you please help me to add time to a form in the Visual Basic integration with powerpoint?

0
uroosa
uroosa
11 years ago

i want to create quiz game in vb6 with database connectivity how???

0
Mark
Mark
11 years ago

I have greated a quiz and its works well, however i would like to use a vba code to work out how long the quiz takes and then convert this is questions right per hour

0
shadow
shadow
10 years ago

How can you prevent the file not to be open within powerpoint. Because, if you open the file within the application they would see all slides.

0
samson
samson
10 years ago

Please email me step by step instruction on how to do a powerpoint quiz .what about doing a power point games

0
Ellen Finkelstein
Ellen Finkelstein
10 years ago
Reply to  samson

I did a search in my blog on “games” and came up with these:
http://www.ellenfinkelstein.com/pptblog/create-a-quiz-in-powerpointdemo-of-technique-7-from-my-e-book/
http://www.ellenfinkelstein.com/pptblog/create-a-quiz-game/
Have fun!

0
Rio
Rio
10 years ago

as a beginner this article say quite understand and very useful for me. thank you

0
Abhishek Kumar
Abhishek Kumar
10 years ago

Hi Ellen

thanks a lot I found it too useful and I knew actual use of macro in ppt.

I am making a game with PowerPoint and I really need this and it is very helpful.

If you know then please tell me for control action button with key board like if I want to move the object or fire by object then how to assign a specific button for it from keyboard in PowerPoint 2010.

Thank you again.

0
ALABI JACOB
ALABI JACOB
10 years ago

Good post, I made a tutorial on my blog with feature of PowerPoint VBA for Great quiz. You can find my blog Here

0
T.G
T.G
10 years ago

Thanks for the tips… Works perfect!

0
dennis
dennis
10 years ago

Thanks for the code.
I also wish to know how one can code macros so that the dialog box will serve as an avenue for password. So that a user needs to put in the required password before the slide moves to the next.
I can find a way out.
I don’t want my kids going through my set questions.
Thanks.

0
Lhay
Lhay
9 years ago

Thanks a lot! It really works perfectly. Now I can make my quizzes more exciting for my students.

0
Ahmed Hassan
Ahmed Hassan
9 years ago

thanks a lot ! it works . but i have a problem i put sound in the macro and gave him the path of sound when i put the power-point file in anther PC it does’t work . how can solve this problem plz ?

0
Sharita Cleland
Sharita Cleland
8 years ago

Nice text, thanks!

0
Stephen Lines
Stephen Lines
8 years ago

Hi Ellen

Clear instructions (thanks), but none of my buttons work (no messages).

I’m using PP 2016 running in Windows 10 which I suspect is the problem/difference.

This is the closest I’ve come to being able to put live quizzes into my presentations. Frustrating, but hoping you or someone out there can help put the final brick in place (probably something ludicrously simple!).

Keep up the good work, and thanks for your unconditional approach to sharing your skills.

Much appreciated,

Stephen

0
Nanda Kishore
Nanda Kishore
8 years ago

Very useful information. I have a question, When i use the Right macro for right answer, it pop-up’s saying click ok, which i click it redirects to next slide. But, I need to put answer source as a button beside OK button when it says correct answer.

If i use MsgBox again, it is feasible to do. But i want this way, Is it Possible ??
Please Suggest me what is the best way to get my output !

0
Kshitij Malik
Kshitij Malik
8 years ago

how can i build a project using ms office applications that can generate various quizzes automatically?

0
wpdiscuz   wpDiscuz

Free Video Training!

13 Techniques that Will Make Designing Your Slides EASY!

And get the PowerPoint Tips Newsletter with tips and resources for presenters. Plus 5 bonus tips!

BirdSend Email Marketing Tool

PresenterMedia

1-on-1 Presentation Coaching

Recent Posts

Recent Posts:

Recent Posts

  • Format multiple headshots for consistency
  • Creating beautiful process diagrams with a teardrop shape
  • Using abstract images to create unique backgrounds for slides and shapes
  • What can online course creators learn from other sectors?
  • Engage your audience with triggers

Connect with me!

Connect with me!


Twitter LinkedIn Facebook

Search the site:

Search the site:

Ellen Finkelstein, Inc. · Fairfield, IA · Tel: 515-989-1832

Privacy, Refund, and Other Legal Stuff

wpDiscuz