Re: update textbox value
- From: Stephen <Stephen@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Jul 2008 10:35:00 -0700
HAHAHAHAAAAAAAAAA IT WORKS!!!
I don't know what was changed other than watching you click yours (jing is
really cool by the way) and renaming it again. The same code I've been trying
since this morning magically works. Thank you for all your help!
"David M. Marcovitz" wrote:
Let's see. Here is an incomplete list of the things you could be doing.
wrong:
(1) You don't have a Dim statement for score listed. Make sure you have
one of those at the top of your module:
Dim score
(2) You are specificying shape 1 on slide 1. Are you sure that the score
textbox is actually shape 1 on slide 1. If it is the first shape you
added to a slide, it is likely shape 3 because the empty placeholders
count as shapes (often shapes 1 and 2).
(3) I'd have to check if your checking the shape type is written
properly because I don't know off the top of my head. You might try
eliminating the If and End If.
(4) Your didn't actually draw a text box to put the score in so not only
is it not shape 1; it doesn't exist at all.
(5) I don't think this is the case for text boxes other than
placeholders (perhaps you are using a placeholder), when you try to
change the text of a placeholder, if there is no text in there at all,
it won't show up. Try typing something in the text box and then running
your procedures.
(6) You aren't clicking on the buttons in Slide Show mode. You can't
click buttons in Normal View.
(7) You aren't clicking the buttons at all.
(8) You have some other error that I don't see in your VBA code so it is
not running at all (try Compiling your code to see if any errors come
up).
--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
=?Utf-8?B?U3RlcGhlbg==?= <Stephen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:8736BA8A-E7D7-4807-A677-7C209201B526@xxxxxxxxxxxxx:
Here's the code I've got in there right now:("ScoreBox").TextFrame.TextRange.Tex
Sub SetScore()
score = 0
End Sub
Sub Add5()
score = score + 5
UpdateScoreTextBox
End Sub
Sub UpdateScoreTextBox()
If ActivePresentation.Slides(1).Shapes(1).Type = msoTextBox Then
ActivePresentation.Slides(1).Shapes
t = score
End If
End Sub
Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub
Sub SetObjectName()
Dim objectName As String
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
objectName = InputBox(prompt:="Type a name for the
object") objectName = Trim(objectName)
If objectName = "" Then
MsgBox ("You did not type anything. " & _
"The name will remain " & _
ActiveWindow.Selection.ShapeRange.Name)
Else
ActiveWindow.Selection.ShapeRange.Name = objectName
End If
Else
MsgBox _
("You can not name more than one shape at a time. " _
& "Select only one shape and try again.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub
I'm using PP 2003 if that makes any difference. I right clicked the
action button, went to action settings and clicked run macro "Add 5"
on the action button I'm using. It's not doing anything though. Even
when I type a random number in the textbox like 7 then run the
SetScore macro (which should set the score to 0) nothing happens. What
am I doing wrong?
Thanks for your help so far, its been great and I would have had no
clue on how to start this without your help. Thank you.
"David M. Marcovitz" wrote:
Ah. Control textboxes behave a little differently. You would need
NameOfTextBox.Text = score
My code was for a regular text box. I forgot to mention that the
regular text box would need to be assigned a name of "ScoreBox" for
my code to work (Example 8.7 on my site gives procedures for naming
text boxes). With a control text box, you can use the properties to
name it NameOfTextBox or just use the default TextBox1.
--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
=?Utf-8?B?U3RlcGhlbg==?= <Stephen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:0031792E-1887-408D-B9FD-BBF757197683@xxxxxxxxxxxxx:
That's exactly what I want to do. I drew a control textbox and
entered a default value of 0 into it. I set the action button to
run macro Slide21.Add43, but when I view as slideshow and click the
answer worth 43 points, the textbox doesn't update...it stays 0.
"David M. Marcovitz" wrote:
OK. Let me see if I understand what you want to do. You have 5
buttons, each worth a different point value. When a button is
clicked, the total number of points is updated and the new value
is displayed in the textbox. Is this correct?
You could get stuff from the buttons or just hard code the point
values. This can be done with one procedure, but it might be
easier to have five. You would associate each button with one of
the procedures. For example (code is untested)
Dim score as Long
Sub Add43()
score = score + 43
UpdateScoreTextBox
End Sub
Sub Add27()
score = score + 27
UpdateScoreTextBox
End Sub
'etc.
Sub UpdateScoreTextBox()
ActivePresentation.Slides(2).Shapes("ScoreBox").TextFrame _
.TextRange.Text = score
End Sub
--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
=?Utf-8?B?U3RlcGhlbg==?= <Stephen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in news:0407A50D-0CEE-47D6-8CC2-AA44839A691E@xxxxxxxxxxxxx:
I figured out how to enable the macros and how to specify which
action button runs which macro. Do I need to get the number of
points for each correct answer from the textbox its typed in as
a string, then save it as a variable thats initial value is
zero? Something like this:
points1=points2=points3=points4=points5=0 UpdatePoints()
if answer1 isClicked then
points1=43
elseif answer2 isClicked then
points2=24
elseif answer3 isClicked then
points3=17
elseif answer4 isClicked then
points4=9
elseif answer5 isClicked then
points5=7
else IncorrectAnswer()
textbox.setText(points1+points2+points3+points4+points5)
then I set all 5 action buttons to run something like this?
"David M. Marcovitz" wrote:
This will require VBA. With VBA, it is quite possible to do it.
I have several score-keeping examples on my site. They are in
the form of quizzes, rather than gameshows, but the basic
concepts should be the same. --David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
=?Utf-8?B?U3RlcGhlbg==?= <Stephen@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in
news:BCE61C3C-A294-4F41-8906-125CE2BAA1F9@xxxxxxxxxxxxx:
I'm putting together a gameshow-type powerpoint and each
slide has a question on it. as the contestants guess answers,
i will click on an action button and make their answer and
the corresponding point value appear. is there a way to have
a textbox that will keep track of points and update everytime
i click the action buttons to reveal the answers?
- Follow-Ups:
- Re: update textbox value
- From: David M. Marcovitz
- Re: update textbox value
- References:
- Re: update textbox value
- From: David M. Marcovitz
- Re: update textbox value
- From: David M. Marcovitz
- Re: update textbox value
- From: Stephen
- Re: update textbox value
- From: David M. Marcovitz
- Re: update textbox value
- From: Stephen
- Re: update textbox value
- From: David M. Marcovitz
- Re: update textbox value
- Prev by Date: Pages with many graphics "flicker" continuously
- Next by Date: Re: update textbox value
- Previous by thread: Re: update textbox value
- Next by thread: Re: update textbox value
- Index(es):
Relevant Pages
|