advanced powerpoint techniques and introduction to vba coding
DESCRIPTION
Advanced PowerPoint Techniques and Introduction to VBA Coding. Dr. Steve Broskoske Misericordia University EDU 533 Computer-based Education. Outline. Advanced PowerPoint Techniques to Deliver CBT Using triggered animation to provide feedback and interactivity. Introduction to VBA Coding - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/1.jpg)
Advanced PowerPoint Techniques and Introduction
to VBA CodingDr. Steve Broskoske
Misericordia University
EDU 533 Computer-based Education
![Page 2: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/2.jpg)
Outline
I. Advanced PowerPoint Techniques to Deliver CBT– Using triggered animation to provide feedback
and interactivity.II. Introduction to VBA Coding
– Set up.– How VBA works: The basics.– Variables.– Concatenation with strings.
![Page 3: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/3.jpg)
Advanced PowerPoint Techniques to Deliver CBT
![Page 4: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/4.jpg)
Introduction
• Not all CBT tasks will require VBA.– If PP can accomplish something without VBA,
don’t reinvent the wheel.– Examples:
• Triggering animations.• Providing basic interactivity on a slide (vs. just
reading slides passively).• Navigating to various slides.
![Page 5: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/5.jpg)
How to Trigger Animations
How to Do It1. Animate an object as usual. 2. Specify a trigger object.
• Select the drop-down arrow from the play-listed item. Select timing.
• Select trigger--start on click of an object. • Select trigger object. (Realize that clipart will
be named as a number.)
![Page 6: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/6.jpg)
Basics of Trigger Animation
The cow jumped over the moon.
![Page 7: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/7.jpg)
Play on Trigger
See the bee fly to the flower.
![Page 8: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/8.jpg)
DEMO: Trigger with Text Boxes
Water. H2O
HCl
NaCl
Hydrochloric acid.
Table salt.
Click an below to view its chemical formula.
![Page 9: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/9.jpg)
TRY IT: Trigger with Text Boxes
Water. H2O
HCl
NaCl
Hydrochloric acid.
Table salt.
Click an below to view its chemical formula.
![Page 10: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/10.jpg)
DEMO: Trigger with Buttons(Provide Options to Learner)
Text number 1. If a learner presses the first button, this text box will appear.
See the definition.
Read more about it.
See a picture.
Answer a question.
![Page 11: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/11.jpg)
TRY IT: Trigger with Buttons(Provide Options to Learner)
Text number 1. If a learner presses the first button, this text box will appear.
See the definition.
Read more about it.
See a picture.
Answer a question.
![Page 12: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/12.jpg)
DEMO: Provide Feedbackwith Triggered Animation
Which of the following is the correct chemical formula for water?
HO H2O H2O2
Correct! Try again!Try again!
![Page 13: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/13.jpg)
TRY IT: Provide Feedbackwith Triggered Animation
Which of the following is the correct chemical formula for water?
HO H2O H2O2
Correct! Try again!Try again!
![Page 14: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/14.jpg)
Introduction to VBA Coding
![Page 15: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/15.jpg)
Set-up: Enabling Macros
• To get VBA to work in PP, you must enable macros.– 2007: Office button – options – trust center –
trust center settings:• enable all macros• trust access to VBA project module
– 2003: Tools – options – security tab (or general tab in old versions of PP)Enable macros here.
![Page 16: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/16.jpg)
Set-up: Finding theVisual Basic Editor
• To begin, you need to be able to access the Visual Basic editor.– 2007: Office button – options – popular –
show developer tab– 2003: Press alt-F11 OR tools—macro—VB
editor
After entering the VBA editor, insert a module to begin.
![Page 17: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/17.jpg)
How VBA Works: The Basics
• Step 1: Type VBA code in the VBA editor.
Sub DisplayMsgBox() MsgBox (“Text in a message box.")End Sub
“Sub” starts every VBA subroutine.
“DisplayMsgBox()” is the name of this
subroutine.
“End Sub” finishes every
VBA subroutine.
Place coding between “subs.”
Indent lines.
![Page 18: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/18.jpg)
How VBA Works: The Basics
• Step 2: Enter “action settings” in a button.– Leave the VBA editor.– Locate a button.– Select its action settings.– Under “run macro,” select a VBA subroutine.
![Page 19: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/19.jpg)
How VBA Works: The Basics
• Step 3: Save a PP file that contains macros (VBA).– Select the following save type: macro-enabled
presentation.– This saves as: filename.pptm– After the initial save, just hit the save button to
save again.
![Page 20: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/20.jpg)
Coding Tips
• Indent code.– Hit tab to indent coding. VBA coders indent
coding to make it easier to read.• Take VBA editor suggestions.
– As you type, the VBA editor will suggest words. To take a suggestion, press space bar.
• Make comments.– The single quote character at the end of a line
allows you to make comments that are disregarded by the editor.
![Page 21: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/21.jpg)
TRY IT
• Let’s type our first VBA coding, and make it work with a button.
Output some textin a message box.
Try it again.
![Page 22: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/22.jpg)
What is a Variable?
• variable: Named location in program code for storing data. Analogous to the memory function on a calculator.
A variable in VBA is like saying in Algebra:
x = 5 OR x = “Dr. Steve”
![Page 23: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/23.jpg)
Declare a Variable
• To use a variable, start by declaring it with a dim statement.– Dim variableName As data_type
Make up a name for a variable. Use capital letters or
underscore (_) for compound names.
Type of variable determines what kind of info. the
variable will hold.
![Page 24: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/24.jpg)
Variable Data TypesData Type Description Range
Integer 16-bit integer -32768 to 32767
Long 32-bit integer ±2 billion (109)
Single 16-bit floating-point value ±3.4 x 1038
Double 32-bit floating-point value ±1.8 x 10308
String characters/text up to 2 billion characters
Boolean true or false false, true
Currency fixed-point fractional value ±1015 with 4 digits of precision
Date date and time Jan. 1, 100 to Dec. 31, 9999
Select specific data type to increase storage efficiency and to restrict type of data stored.
![Page 25: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/25.jpg)
Examples of Variable Declarations
• How to declare a variable:
Dim n As IntegerDim n As SingleDim myName As StringDim flag As Boolean
• How to assign a value to a variable:
n = 15n = 2.146myName = “Dr. Steve”flag = true
Most commonly used variable types.
![Page 26: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/26.jpg)
Examples of Variable Declarations
• You can also declare several variables in the same statement:
Dim n As Integer, myName As StringDim a, b, c, n As Integer, total As LongDim n As Integer
![Page 27: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/27.jpg)
TRY IT
Declare a variable to hold a whole number.Assign a value.
Output in a message box.
Declare a variable to hold a decimal number.
Assign a value.Output in a message box.
Declare a variable to hold text.
Assign a value.Output in a message box.
Declare a variable to hold a true/false value.Assign a value.
Output in a message box.
![Page 28: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/28.jpg)
Local vs. Public Variables
• Where a variable is declared affects how it functions.– public variable: A variable that is declared as
public is “alive” and available to all subroutines throughout the project. Declare a public variable at the top of the form.
– private variable: A variable that is declared within one subroutine is “alive” only as long as the subroutine is running. Declare a private variable within one subroutine.
![Page 29: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/29.jpg)
Local vs. Public Variables
• Declare a variable according to when you need to use it:– Local: Declare a local variable if you only
need to use this variable within this one procedure only (e.g., to count something while this procedure runs, or to temporarily store something).
– Public: Declare a public variable if you want to assign or recall its contents out side of one procedure (i.e., on more than one slide). It’s like a calculator memory.
![Page 30: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/30.jpg)
TRY IT
Declare a public variable.Assign a value.
Output in a message box.
Declare a local variable.Assign a value.
Output in a message box.
Output a variablein a message box.
![Page 31: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/31.jpg)
Concatenation with Strings
• If you want to add 2 strings together, use concatenation (the & character).– Add a string and a string variable.
Dim userName As StringuserName = “Dr. Steve”MsgBox ("Your user name is " & userName)
Notice blank space.
![Page 32: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/32.jpg)
TRY IT
• ConcatLocal()• ConcatPublic()
Declare a LOCAL string variable.Assign a value.
In msgbox, concatenate text and variable for output.
Declare a PUBLIC string variable.Assign a value.
In msgbox, concatenate text and variable for output.
![Page 33: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/33.jpg)
Concatenation with Strings
• You can add additional strings of text to a string variable.
• Dim sentence As String
Sub addStrings() sentence = “Hi.” sentence = sentence & “How are you?” sentence = sentence & “Take care.”End Sub
![Page 34: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/34.jpg)
TRY IT• Declare sentence a public variable to hold text.• initializeSentence()• addToSentence()• printSentence()
Assign an initial value to sentence.
Output the value of sentence in a message box.
Add a value to whatever is already contained in sentence.
![Page 35: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/35.jpg)
TRY IT• Declare public variables:
– age and maxcount to hold whole numbers– longSentence to hold text
• initializeVariables()– Assign values to age and maxcount.
• makeLongSentence()– Print out child age and how high they can count in a
sentence.
Initialize variables. Print out sentence.
![Page 36: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/36.jpg)
Reminder: Saving
• Remember that you once you add VBA to PP, you must save the PP file as one that contains macros (VBA).– Select the following save type: macro-enabled
presentation.– This saves as: filename.pptm– After the initial save, just hit the save button to
save again.
![Page 37: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/37.jpg)
Assignments
![Page 38: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/38.jpg)
Assignments
1. Set up PowerPoint so that you can access the VBA editor and access macros within PowerPoint.
![Page 39: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/39.jpg)
Assignments
2. Download the homework assignment from our Web page. It asks you to do the following:– Non-VBA activities:
• Trigger animations.– VBA activities:
• Declare and output in a MsgBox the following types of variables: string, integer, short, and Boolean.
• Concatenate a string variable.• Save the application appropriately.
![Page 40: Advanced PowerPoint Techniques and Introduction to VBA Coding](https://reader036.vdocuments.site/reader036/viewer/2022081503/568164ae550346895dd6ba21/html5/thumbnails/40.jpg)
Next Week
• Creating embedded formative assessment.– Working with variables.– Working with conditional statements.– Working with object properties.