Here is a summary of the code snippets used in these tutorials.
![]() |
|
![]() |
|
- To break a long line of code over two lines:
Use a space, then the underscore character
- To make a pop up message box: (In this example to say Hello)
msgBox("Hello")
- To join strings or variables in message boxes: (use & operator)
msgBox("Hello" & userName)
- To ask for and store the user's name: (in a variable called userName)
userName = InputBox(prompt:="What is your name?", Title:="Input Name")
- To go to another slide (In this example to go to slide 3):
ActivePresentation.SlideShowWindow.View.GotoSlide 3
- To go to the next slide
ActivePresentation.SlideShowWindow.View.Next
- To go to the previous slide
ActivePresentation.SlideShowWindow.View.Previous
- To go to the first slide
ActivePresentation.SlideShowWindow.View.First
- To go to the Last slide
ActivePresentation.SlideShowWindow.View.Last
- To exit the Slide Show
ActivePresentation.SlideShowWindow.View.Exit
- To hide an object (In this case the 4th object on Slide 3):
ActivePresentation.Slides(3).Shapes(4).Visible = False
To make it visible again, use:
ActivePresentation.Slides(3).Shapes(4).Visible = True
- The following line of code will change the font colour of text frame 1 on slide 2:
ActivePresentation.Slides(2).Shapes(1).TextFrame.TextRange.Paragraphs(1).Font.Color = RGB(255, 0, 0)
(RGB values can range from 0 to 255 - the first number is for Red, the second is for Green and the third is for Blue)
- The following line of code will change the font size of text frame 1 on slide 2 to 40 point size:
ActivePresentation.Slides(2).Shapes(1).TextFrame.TextRange.Paragraphs(1).Font.Size = 40
- The following line of code will change the font of text frame 1 on slide 2 to bold:
ActivePresentation.Slides(2).Shapes(1).TextFrame.TextRange.Paragraphs(1).Font.Bold = True
- The following line of code will change the font of text frame 1 on slide 2 to italic:
ActivePresentation.Slides(2).Shapes(1).TextFrame.TextRange.Paragraphs(1).Font.Italic = True
- If ... then...else
If userAge < 20 then msgBox("Cool... let's have some fun!") else _
msgBox("Don't you think you're a bit old for this sort of thing!")
- Blocked if statements
If condition-1 Then
statementsElseIf condition-2 Then
elseifstatements...Else
elsestatementsEnd If
Notes: If/Then must be on the same line, Must finish with End If, ElseIf/Then must be on same line
- Select Case
Select case userAge
case <20
msgBox("Wow, you're really young")
case <40
msgBox ("It's about time you started to act your age")
case <60
msgBox("Wow! That's really old!")
case else
msgBox("Isn't it about time you booked a plot?")
end Select
Loops: Do... While
Do While userName=""
userName = InputBox(prompt:="Please type your name!", _ Title:="Input Name")
Loop
Loops: For Next'
For Counter = 1 to 5
Eat lolly
Next Counter
The following line will play a Beep sound
Beep



