VBA code

G

Gary in AZ

I'm writing a PPT-based tic-tac-toe game for a college class. I was going to
insert 2 invisiple objects in each square and record macros so that if you
clicked on the first object, an X would appear. Clicking on the second object
would cause an O to appear. Apparently, PPT 07 does not allow direct
recording of macros. You have to use VBA - (a little over my head at this
point). I can't hyperlink around like most games because there are too many
X/O combinations. I have to be able to put the X's & O's on a single slide.

Could anyone walk me through the process for writing this VBA code. (Or if
there is some other way to do this, I'm all ears)

Thanks
 
D

David Marcovitz

On 11/20/09 8:14 AM, in article
(e-mail address removed), "Gary in AZ" <Gary in
I'm writing a PPT-based tic-tac-toe game for a college class. I was going to
insert 2 invisiple objects in each square and record macros so that if you
clicked on the first object, an X would appear. Clicking on the second object
would cause an O to appear. Apparently, PPT 07 does not allow direct
recording of macros. You have to use VBA - (a little over my head at this
point). I can't hyperlink around like most games because there are too many
X/O combinations. I have to be able to put the X's & O's on a single slide.

Could anyone walk me through the process for writing this VBA code. (Or if
there is some other way to do this, I'm all ears)

Thanks

Gary,

You just (correctly) suggested to another user that animations might be the
best way to go. That might be true for you as well. Why can't you have the
X's and O's be triggered by the clicks on your invisible buttons.

If you want to use VBA, I have been finding that the 2007 occasionally has
problems with macros that adjust the .Visible property of a shape. What I
have been recommending to my students is to adjust the .Top property of a
shape so it is off the screen (e.g. .Top = 3000) to make the shape invisible
and then put it back to normal (e.g. .Top = 150) to make the shape visible.

You will also need a procedure (probably run from the first slide) to set
the board up. If you were just dealing with two shapes, and you were to use
the .Visible property) the code would look something like this:

Sub Initialize()
ActivePresentation.Slides(2).Shapes("X1").Visible = msoFalse
ActivePresentation.Slides(2).Shapes("O1").Visible = msoFalse
End Sub

Sub ShowX1()
ActivePresentation.Slides(2).Shapes("X1").Visible = msoTrue
End Sub

Sub ShowO1()
ActivePresentation.Slides(2).Shapes("O1").Visible = msoTrue
End Sub

To avoid the problem with the Visible property, you could change .Visible =
False to .Top = 3000, and .Visible = True to .Top = 150 (or whatever will
get the shape in the right spot on the slide).

The other thing that you need to do is name all your shapes (you can see
shape-naming code on my site -- http://www.PowerfulPowerPoint.com/ -- in
Example 8.7).

--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
G

Gary in AZ

David,

Thank you very much for your response. I'm getting a book on VBA, but the
learning curve will probably take a while. I am pretty proficient in PPT,
but have no idea how to trigger the X & O by clicking on the object. How is
this possible?

Thank you again for your help.

Gary
 
D

David Marcovitz

There are many tutorials on animation triggers that will help you if you
choose to go that route. Here are some examples:

http://pptheaven.mvps.org/tutorials/trigger.html

http://www.indezine.com/products/powerpoint/cool/trigger01.html

http://office.microsoft.com/en-us/powerpoint/HA010873001033.aspx

--David

David,

Thank you very much for your response. I'm getting a book on VBA, but the
learning curve will probably take a while. I am pretty proficient in PPT,
but have no idea how to trigger the X & O by clicking on the object. How is
this possible?

Thank you again for your help.

Gary

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 

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