PowerPoint tips, hints and tutorials that will change your presentations for ever!



Custom Shows
vba code
Games for teachers
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Set spellcheck language

Home buttonTutorial buttonContact buttonProducts button

Office  vba

If you are learning vba in Office probably the first thing you learned to do was pop up a message box.

Sub Pop_Up()
MsgBox "Hello World"
End Sub

Message box

But There's Much More to Message Boxes!

First in your vba editor type a comma after the message. You should get a pop up of all the available styles of box. This is "Information" but you can experiment!

Pop up in vbe

Information Box

Experiment a little before you continue ...

Some of the more useful types have extra buttons like Yes No Cancel. We will see how to use these shortly. For now though lets change the Title "Microsoft PowerPoint" to a custom title.

Here's the code ...

Sub Pop_Up()
MsgBox "Hello World", vbInformation, "My Message"
End Sub

Custom Title

Suppose you want to ask a question and do different things depending on the answer?

Sub Cancel_Me()

 ' If you don't press NO then cancel - The brackets are important
If MsgBox("Do you want to cancel?", vbYesNo)<> vbNo Then Exit Sub
MsgBox "If you see this you didn't cancel!"
End Sub

This code pops up a box and if you click "No" it continues, otherwise it exits.

So far so good? Well suppose you want a "question" type box AND a "yes / No" box. Something like this:

Two types at once

Here's the way to code this with a "+" sign.

Sub Cancel_Me()
If MsgBox("Do you want to cancel?", vbYesNo + vbQuestion) = vbYes Then Exit Sub
MsgBox "If you see this you didn't cancel!"
End Sub

Only certain combinations are allowed!


Back to the Index Page


Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation