Previous Thread:   Launch Powerpoint Template from Word

9/30/2005 12:53:21 PM    hiding and showing objects with script
I'm creating an interactive quiz in Powerpoint. I have created 2  
  
possible answers to a question. Each is a button object. If the user  
  
clicks on button 1, which is correct, then Sub Correct() in the general  
  
script is called. If they click on button 2, then Sub Wrong()is called  
  
up.  
  
So far, this script works fine:  
  
Sub Correct()  
  
MsgBox ("Correct!")  
  
End Sub  
  
Sub Wrong()  
  
MsgBox ("Sorry, that is incorrect!")  
  
End Sub  
  
HOWEVER, IT CALLS UP THE MESSAGE BOX, which I think is ugly and  
  
disappears in the screen.  
  
INSTEAD, I would like it so that when you click on the correct answer  
  
it displays an object that has a nice bitmap associated with it.  
  
So, I created two objects on the screen, associated them each with a  
  
specific bitmap and named the objects Green1 and Red1. Then, using  
  
Properties, I made them hidden.  
  
I modified the script as follows:  
  
Sub Correct()  
  
ActivePresentation.Slides(40).Shapes(Green1).Visible = msoTrue  
  
End Sub  
  
Sub Wrong()  
  
ActivePresentation.Slides(40).Shapes(Red1).Visible = msoTrue  
  
End Sub  
  
HOWEVER, NEITHER OF THESE ARE WORKING.  
  
Am I calling these objects incorrectly? Any help would be appreciated.  
  
Thanks!



9/30/2005 1:00:45 PM    Re: hiding and showing objects with script
You are definitely on the right track. You need to name the objects  
  
Green1 and and Red1. You can use procedures like those in Example 8.7 on  
  
my site to name objects:  
  
http://www.loyola.edu/education/PowerfulPowerPoint/  
  
Click on "Examples by Chapter" and "Chapter 8." Next, you need to put  
  
quotes around the name of your objects in in your procedure. For example,  
  
ActivePresentation.Slides(40).Shapes("Green1").Visible = msoTrue  
  
You might want to look at Examples 6.4 and 6.6 on my site for simple  
  
examples of exactly what you are trying to do.  
  
--David  
  
--  
  
David M. Marcovitz  
  
Microsoft PowerPoint MVP  
  
Director of Graduate Programs in Educational Technology  
  
Loyola College in Maryland  
  
Author of _Powerful PowerPoint for Educators_  
  
http://www.loyola.edu/education/PowerfulPowerPoint/  
  
"Robin" <rsowton@comcast.net> wrote in news:1128110001.539998.193720  
  
@g47g2000cwa.googlegroups.com:

9/30/2005 1:18:35 PM    Re: hiding and showing objects with script
Thanks David. I finally got it to work using this script (see below).  
  
However, I may end up getting your book eventually, because I haven't  
  
seen many other resources available for learning how to script  
  
interactivity into Powerpoint.  
  
Robin  
  
---------------------  
  
Sub Correct()  
  
Green1.Visible = msoTrue  
  
Red1.Visible = False  
  
End Sub  
  
Sub Wrong()  
  
Red1.Visible = msoTrue  
  
Green1.Visible = False  
  
End Sub  
  
Sub Correct1_Click()  
  
Green1.Visible = False  
  
End Sub  
  
Sub Wrong1_Click()  
  
Red1.Visible = False  
  
End Sub

9/30/2005 1:28:09 PM    Re: hiding and showing objects with script
Aha! You are using Active X control objects, rather than regular buttons.  
  
Now I understand what you are trying to do. Objects like that are good  
  
for some things and not as good for other things. My answer to your  
  
question was based on the assumption that you were using the regular  
  
PowerPoint objects.  
  
The only reason why I wrote the book was because there was nothing else  
  
available. I would have been much happier if I had just been able to go  
  
out and by a book, instead of having to write one myself.  
  
--David  
  
--  
  
David M. Marcovitz  
  
Microsoft PowerPoint MVP  
  
Director of Graduate Programs in Educational Technology  
  
Loyola College in Maryland  
  
Author of _Powerful PowerPoint for Educators_  
  
http://www.loyola.edu/education/PowerfulPowerPoint/  
  
"Robin" <rsowton@comcast.net> wrote in news:1128111515.956780.199780  
  
@g49g2000cwa.googlegroups.com: