vba PowerPoint and Shapes

G

Guest

Hello. Almost completely new to scripting in PowerPoint but wonder if anyone
can direct me.

I am using PowerPoint 2003, and want to add a bunch of shapes to a slide.
When one shape is clicked, you jump to a different slide. When you click back
to the original slide, the shape(s) that have already been clicked are set to
0% visibility, or are dimmed. Does anyone have any idea how this is done?

Thanks very much!!
 
D

David M. Marcovitz

You could do this without scripting, using trigger animations. You could
also do this with scripting with something like:

Sub DimAndGo(oShp As Shape)
oShp.Fill.ForeColor.RGB = vbBlue
ActivePresentation.SlideShowWindow.View.GotoSlide 3
End Sub

Change vbBlue to some other suitable dimming color and 3 to some other
suitable slide number.

--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.PowerfulPowerPoint.com/
 
G

Guest

This doesnt require vba code.
Give each shape an action setting to hyperlink wherever and also an emphasis
effect > desaturate

Double click the emphasis entry in custom animation and in timing set it to
start effect on click of trigger = itself
--
 
G

Guest

For PowerPoint 2003, you can use triggers.
First, go to Custom Animation and add Emphasis (Transparency) to all the
shapes.
Double click on the first effect you have added, click Timing tab.
Click Triggers and select "Start effect on click of".
Click on the dropdown field, look for this shape that you are animating on,
have it trigger on itself.
Repeat steps on other autoshapes.

Finally, add a "Next page" hyperlink or a hyperlink to different slides on
the autoshapes.
--
Shawn Toh (tohlz)
Microsoft Most Valuable Professional (MVP PowerPoint)

Site Updated: June 08, 2006
Added PowerPoint Movies.
http://pptheaven.mvps.org
PowerPoint Heaven - The Power to Animate
 
G

Guest

Thanks for the info. If I do it this way (VBA vs. triggers), do I need some
sort of onClick event handler in the script? How about if I have multiple
shapes? Does each shape need some sort of unique name/information?

The trigger suggestions are working pretty well, however I wonder if the
script option might solve for the fact that I click and go to another slide,
and then when I click a link to return, the initial shape is on the slide for
a quick moment before it disappears. Would not want the object to be there
when I return to that slide.

Thanks!
 
G

Guest

You can adapt the code above so that the shape is invisible

Sub DimAndGo(oShp As Shape)
oShp.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.GotoSlide 3
End Sub

Set an action setting on the shape to Run macro "DimandGo"

A problem you will find is once invisible its not that easy to get it back
unless you write more code to reset it ti msotrue. The original code to
change colour is safer.
--
-----------------------------------------
Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
 
G

Guest

Patrick, if you are using trigger, you can have the shape staying there for a
quick moment before it disappear as well. You will need to make use of delay.
If you are using Emphais (Transparency) effect, set the transparency effect
to 100%.
Alternately, use Exit (Disappear) effect works too.

Next, double click on the effect and go into the timing tab.
Under timing, there is a delay where you can set 'x' seconds before the
effect starts to trigger itself.
For instance, if you set it to 2 seconds, when you click on the shape, it
will jump into another slide. Then, when you hyperlink back to that slide,
the shape will stay there for 2 seconds before it disappear.
--
Shawn Toh (tohlz)
Microsoft Most Valuable Professional (MVP PowerPoint)

Site Updated: June 08, 2006
Added PowerPoint Movies.
http://pptheaven.mvps.org
PowerPoint Heaven - The Power to Animate
 
D

David M. Marcovitz

No, you do not need any special event handlers. All you need to do is set
the action settings for any shape to DimAndGo. It automatically takes care
of the shape that was clicked.

Yes, the VBA can be written so the shape is not visible at all when you get
back. If you want to make it invisible, you need:

oShp.Visible = msoFalse

As John pointed out, the problem with making shapes invisible is making
them visible again. The way I generally solve this is with a procedure that
I link to a button on the first slide. That procedure is used to set
everything up the way I want it (including hiding or unhiding shapes and
initializing variables and resetting shape colors). You can see an example
of this at my site

http://www.PowerfulPowerPoint.com/

We seem to be having a temporary problem with our site this morning, so if
that link doesn't work, you can go to:

http://webdev.loyola.edu/dmarco/education/PowerfulPowerPoint/

The simplest example is Example 5.5. This actually hides shapes in my
Initialize procedure because I don't want the stars to be visible when you
start, but you could easily have it unhide things (changing False to True).
The problem is that you have a whole bunch of shapes that you will want to
unhide. You could either list them one by one in an Initialize procedure,
or you could write a simple routine to unhide everything:

Sub UnhideItAll()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld in ActivePresentation.Slides
For Each oShp in oSld.Shapes
oShp.Visible = msoTrue
Next oShp
Next oSld
End Sub

This should unhide EVERY shape in the presentation, but I just scribbled it
down off the top of my head without testing so I don't guarantee it works.

--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.PowerfulPowerPoint.com/
 
G

Guest

I AM SO CLOSE! Thanks, first off, for your help...I am nearly there. The
current script works fine...

Sub DimAndGo(oShp As Shape)
oShp.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.GotoSlide 3
End Sub

And the unhiding works too. Question: I have multiple shapes on slide 1.
Each shape should become invisible once clicked, but clicking each shape
should advance the show to a different slide (i.e., click shape 1 to go to
page 2, click shape 2 to go to page 3, but each should be invisible when I
return).

How is this possible??

Thanks!
 
D

David M. Marcovitz

If the shapes have to go to different places, then you have two choices:

(1) Use multiple DimAndGo procedures, such as:

Sub DimAndGo3(oShp As Shape)
oShp.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.GotoSlide 3
End Sub

Sub DimAndGo4(oShp As Shape)
oShp.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.GotoSlide 4
End Sub

etc.

Attach each procedure to the appropriate button.

(2) Find a way to use the properties of the shape to tell you where to go
so you can only have one procedure. For example, if the text of the
button is the number of the slide to go to, you could do something like
this (untested and without error checking so use at your own risk):

Sub DimAndGo(oShp As Shape)
oShp.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.GotoSlide _
oShp.TextFrame.TextRange.Text
End Sub

Other code could be written based on parts of the text or location of the
shape or ..., but it is probably easier to do a little copying and
pasting and just have a bunch of slightly different procedures.

--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.PowerfulPowerPoint.com/
 
S

Steve Rindsberg

Rats. I pushed the button on an example that does more or less this but it
seems to have disappeared. But see the mod to your code below:
(2) Find a way to use the properties of the shape to tell you where to go
so you can only have one procedure. For example, if the text of the
button is the number of the slide to go to, you could do something like
this (untested and without error checking so use at your own risk):

Sub DimAndGo(oShp As Shape)
oShp.Visible = msoFalse
' ActivePresentation.SlideShowWindow.View.GotoSlide _
' oShp.TextFrame.TextRange.Text
' The parent of the current shape is the slide
' so we can get the slide index from that:
ActivePresentation.SlideShowWindow.View.GoToSlide _
oShp.Parent.SlideIndex + 1

End Sub
 
D

David M. Marcovitz

Hmm. The current slide is the first slide, so wouldn't this always take you
to the second slide. Unless I misunderstood the problem. I thought the OP
had a bunch of shapes on one slide that each would take you to various
slides.
--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.PowerfulPowerPoint.com/
 
S

Steve Rindsberg

David M. said:
Hmm. The current slide is the first slide, so wouldn't this always take you
to the second slide. Unless I misunderstood the problem. I thought the OP
had a bunch of shapes on one slide that each would take you to various
slides.

Twisted threads? You're right ... I'm thinking of something else here.

Wish I could remember what! ;-)
 
G

Guest

It looks like this all worked and that the requestor is pleased with the
result. Could not have done this without everyone's help, and I thank you
very much for your time and for sharing your knowledge.

Thanks!
 
D

David M. Marcovitz

Great! I'm glad it all worked out for you and the requestor. Thanks for
getting back to us.
--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.PowerfulPowerPoint.com/
 

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