vba code for ms powerpoint

H

Hai Nguyen

Hello,
I am a newbie to vba for ms power point. I want to create a vba macro that
allow me to remove an action button and reveal texts below it upon clicking
this action button but I do not know how to do it. I have been searching for
the vba code using Google without success so far.

Thanks.

Hai Nguyen.
 
B

Bill Dilworth

The difficulty with doing this is not getting the text to appear, but with
getting the action button to disappear. The action buttons tend not to
update the same as other objects in PowerPoint.

You may be better off using a regular shape with an action setting. Say we
make a shape called "PressThis" and another shape with text that is called
"ShowThis" Then you could add the code that looks like this:

=====Start Code ======

Sub ButtonPressed()

With ActivePresentation.Slides(1).Shapes
.Item("ShowMe").Visible = msoTrue
.Item("PressMe").Visible = msoFalse
End With

End Sub


Sub ButtonReset()

With ActivePresentation.Slides(1).Shapes
.Item("ShowMe").Visible = msoFalse
.Item("PressMe").Visible = msoTrue
End With

End Sub

=====End Code ======

Now connect it together by right clicking on the PressMe shape and set the
action setting
'when clicked' to
'Run the Macro'
"ButtonPressed"

To reset the 2 objects set the ShowMe text to Run the Macro ButtonReset.
(Otherwise, you'll be wondering how to get the button back.)


** HOWEVER **

You do not need VBA to make this happen. You can use a simple trigger
animation.

Set the animation on the text box to appear, then click on the animation
timing to show the timing dialog. Click on the Triggers button and select
the Shape name that will trigger the text to show. OK out of everything.


The trigger method is easier and with work in more cases.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
B

Brian Reilly, MVP

Hai,
You could cut Bill's code in half and just have one routine

Sub show_hide()
With ActivePresentation.Slides(1).Shapes
.Item("ShowMe").Visible = Not .Visible
.Item("PressMe").Visible = Not .Visible
End With
End Sub

Easier to manage if it's all in one place (g)

Brian Reilly, MVP
 

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