A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA code



 
 
Thread Tools Display Modes
  #1  
Old November 20th, 2009, 01:14 PM posted to microsoft.public.powerpoint
Gary in AZ
external usenet poster
 
Posts: 1
Default VBA code

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
  #2  
Old November 20th, 2009, 02:29 PM posted to microsoft.public.powerpoint
David Marcovitz
external usenet poster
 
Posts: 647
Default VBA code

On 11/20/09 8:14 AM, in article
, "Gary in AZ" Gary in
wrote:

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


  #3  
Old November 21st, 2009, 12:58 AM posted to microsoft.public.powerpoint
Gary in AZ[_2_]
external usenet poster
 
Posts: 5
Default VBA code

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 Marcovitz" wrote:

On 11/20/09 8:14 AM, in article
, "Gary in AZ" Gary in
wrote:

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


.

  #4  
Old November 21st, 2009, 02:33 AM posted to microsoft.public.powerpoint
David Marcovitz
external usenet poster
 
Posts: 647
Default VBA code

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/pow...trigger01.html

http://office.microsoft.com/en-us/po...873001033.aspx

--David

On 11/20/09 7:58 PM, in article
, "Gary in AZ"
wrote:

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 Marcovitz" wrote:

On 11/20/09 8:14 AM, in article
, "Gary in AZ" Gary in
wrote:

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


.


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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.