Animate TextBox Control with VBA, for quiz

M

misscrf

I have been working on some PowerPoint animation that works like a
quiz. A list box has possible answers, and depending on the answer
they choose, a textbox has a certain value and color to it. I would
also like to animate the text box so it looks slick. Here is the code
I have so far:

Private Sub ListBox1_Click()
If ListBox1 <> "" Then
answer = ListBox1

If answer = "My Answer 1" Then
txtExample = "That's part right, but there's more!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(128, 0, 255)
'Color - Purple
txtExample.BackColor = RGB(0, 255, 255)
'Color - Cyan
txtExample.BorderColor = RGB(0, 0, 0)
'Color - Black

ElseIf answer = "My Answer 2" Then
txtExample = "That's kinda sorta right, but there's some more!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(0, 191, 255)
'Color - Deep Sky Blue
txtExample.BackColor = RGB(173, 255, 47)
'Color - Green Yellow
txtExample.BorderColor = RGB(255, 20, 147)
'Color - Deep Pink

ElseIf answer = "My Answer 3" Then
txtExample = "There's more, but that is part of it!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(240, 128, 128)
'Color - Light Coral
txtExample.BackColor = RGB(216, 191, 216)
'Color - Thistle
txtExample.BorderColor = RGB(218, 165, 32)
'Color - Goldenrod

ElseIf answer = "My Correct Answer 4" Then
txtExample = "WOHOOOOOO!!!!! You Got it Right!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(208, 32, 144)
'Color - Violet Red
txtExample.BackColor = RGB(245, 245, 220)
'Color - Beige
txtExample.BorderColor = RGB(0, 250, 154)
'Color - Green
End If
End If
End Sub

All of this works, and now I jsut also want to add a line for each
answer like

docmd.animation = fly in left

or

txtExample.entrance = (flyin, Left)
lol
I know that's not right, but I am guessing someone out there might know
what would be right. Is there also a list of the vba names for the
animations for entrance and emphasis, etc?

Thanks!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
A

Austin Myers

Go to the Microsoft web site and do a search for a file called
"vbapp10.chm". This is the documentation for the PowerPoint Object Model.
It should be a big help.


Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
S

Steve Rindsberg

Misscrf said:
I have been working on some PowerPoint animation that works like a
quiz. A list box has possible answers, and depending on the answer
they choose, a textbox has a certain value and color to it. I would
also like to animate the text box so it looks slick. Here is the code
I have so far:

Private Sub ListBox1_Click()
If ListBox1 <> "" Then
answer = ListBox1

If answer = "My Answer 1" Then
txtExample = "That's part right, but there's more!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(128, 0, 255)
'Color - Purple
txtExample.BackColor = RGB(0, 255, 255)
'Color - Cyan
txtExample.BorderColor = RGB(0, 0, 0)
'Color - Black

ElseIf answer = "My Answer 2" Then
txtExample = "That's kinda sorta right, but there's some more!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(0, 191, 255)
'Color - Deep Sky Blue
txtExample.BackColor = RGB(173, 255, 47)
'Color - Green Yellow
txtExample.BorderColor = RGB(255, 20, 147)
'Color - Deep Pink

ElseIf answer = "My Answer 3" Then
txtExample = "There's more, but that is part of it!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(240, 128, 128)
'Color - Light Coral
txtExample.BackColor = RGB(216, 191, 216)
'Color - Thistle
txtExample.BorderColor = RGB(218, 165, 32)
'Color - Goldenrod

ElseIf answer = "My Correct Answer 4" Then
txtExample = "WOHOOOOOO!!!!! You Got it Right!"
txtExample.SpecialEffect = fmBorderStyleSingle
txtExample.ForeColor = RGB(208, 32, 144)
'Color - Violet Red
txtExample.BackColor = RGB(245, 245, 220)
'Color - Beige
txtExample.BorderColor = RGB(0, 250, 154)
'Color - Green
End If
End If
End Sub

All of this works, and now I jsut also want to add a line for each
answer like

docmd.animation = fly in left

I'm no animation wizard, but I think this'll do it:

txtExample.AnimationSettings.EntryEffect = ppEffectFlyFromLeft
 
M

misscrf

Thank you for your responses. Steve, I did try the
txtExample.Animationsettings = pp....

That wasn't working either. I found it was easier to make a bunch of
text boxes. 4 set up to look like a list box. Then 4 more. each 1
acts on a trigger of 1 of the first 4. So if I click 1 a text box will
animate and enter telling me I am wrong, and then dissappear. If I
click 2, I get a different text box with same behavior, and so on.

Now, I just need to figure out how to reset the textboxes at the end of
the slideshow. Anyone know how to do this?

A bunch of them are named TextBox1, and I don't think it likes that.
If I run TextBox1.text = ""
on a slide where there is one, it clears that one.

If I try it at the end of the presentation to clear them all, it
doesn't work. :-(

Any thoughts?
 
S

Steve Rindsberg

Now, I just need to figure out how to reset the textboxes at the end of
the slideshow. Anyone know how to do this?

A bunch of them are named TextBox1, and I don't think it likes that.
If I run TextBox1.text = ""
on a slide where there is one, it clears that one.

If I try it at the end of the presentation to clear them all, it
doesn't work. :-(

Any thoughts?

What type of text boxes are they? Did you create them from the Controls menu
or with the Text Box tool on the drawing toolbar?

You'll need some way to identify them (that is, tell them apart from the other
text boxes on the same slides).

You might want to rename each of the shapes you want to clear. For example, if
you give them all names starting with a unique string like "XXX" so you've got
XXXText1, XXXText2 and so on, you could:

Sub ClearEmDanO()
Dim oSl as Slide
Dim oSh as Shape
For Each oSl in ActivePresentation.Slides
For Each oSh in oSl.Shapes
If Left$(oSh.Name,3) = "XXX" Then ' a TARGET!
oSh.TextFrame.TextRange.Text = ""
End If
Next
Next
End Sub
 
S

Steve Rindsberg

Steve,

Thank you so much for this helpful response. Unfortunately, the textbox
controls that I am using are vba textbox controls, rather than drawing text
box frames.

Familiar with reseting their value?

For arguments sake, let me convey the names I gave to the question slides
with textbox controls that need to be reset.

I set them to the following (there are 3):

SldA and txtA on that slide
SldB and txtB for the 2nd question slide
SldC and txtC for the last question

OK .. let's try this for starters:

Sub DueTheTextBoxes()
With ActivePresentation.Slides("SldA").Shapes("txtA")
.OLEFormat.Object.Text = ""
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top