Need some help with VBA in PowerPoint Presentation

K

Keith

Hello,

I have a Powerpoint slide with four button controls. I’m trying to set up a
slide to demonstrate an elusive idea. When the slide is presented, the
viewer sees button 1. When the cursor hovers over button 1 it disappears and
button 2 appears, when the cursor hovers over button 2, it disappears and
button 3 appears, and so on with button 4, and back to button 1. I tried the
code shown below for buttons 1 through 4. It seems they should work if the
first function “my_start_up_function()†were to run when the slide is
displayed. Well, it doesn’t work. How can I accomplish this task?

Thank you


Private Sub my_start_up_function()

CommandButton1.Visible = True
CommandButton2.Visible = False
CommandButton3.Visible = False
CommandButton4.Visible = False

End Sub

Private Sub CommandButton1_GotFocus()

CommandButton1.Visible = False
CommandButton2.Visible = True

End Sub

Private Sub CommandButton2_GotFocus()
CommandButton2.Visible = False
CommandButton3.Visible = True
End Sub

Private Sub CommandButton3_GotFocus()
CommandButton3.Visible = False
CommandButton4.Visible = True
End Sub

Private Sub CommandButton4_GotFocus()
CommandButton4.Visible = False
CommandButton1.Visible = True
End Sub
 
B

Bill Dilworth

The ActiveX controls on a slide do not update visibility well. This has
been a problem for several versions.

To solve this problem, you will need to force a slide re-rendering. To do
this, the easiest way might be to ...

1) Insert a slide that looks the same as your slide, only without any
buttons, just before your slide.
2) Set this new slide to auto-advance (on the transitions pane) in 0:00
seconds
3) Add a small new sub to your code

------
Sub RedrawMySlide()

If SlideShowWindows.Count > 0 Then
With SlideShowWindows(1)
If .View.CurrentShowPosition > 1 Then
.View.GotoSlide _
.View.CurrentShowPosition -1
End If
End With
End If

End Sub
-------

And change your current subs to reflect this format
------
Private Sub CommandButton1_GotFocus()

CommandButton1.Visible = False
CommandButton2.Visible = True
RedrawMySlide

End Sub
------





Wait wait wait....... Hold the phone here.

You said 'hover over', not 'click on'. Ok this changes everything. I would
1) not use command buttons, but shapes that look like command buttons 2) Use
action settings with mouse over settings that do the functions you want.

4 shapes on one slide

Shape 1 action setting set as Mouse over, run macro "Shape1Code"
shape 2 ... shape x coded in the same fashion

Sub Shape1Code()
'change the various shapes visibility to suit
end sub




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

David M. Marcovitz

As Bill said, use regular buttons, not control buttons. I don't think
Got_Focus will activate on mouse over. Name your buttons, Button1,
Button2, Button3, Button4 and use:

Sub Button1Stuff()
ActivePresentation.SlideShowWindow.View.Shapes("Button1") _
.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.Shapes("Button2") _
.Visible = msoTrue
ActivePresentation.SlideShowWindow.View.Shapes("Button3") _
.Visible = msoFalse
ActivePresentation.SlideShowWindow.View.Shapes("Button4") _
.Visible = msoFalse
End Sub

Then make three more of these procedures, just changing the true and
false values as needed. Then set these procedures to be the ActionSetting
on MouseOver for the various buttons.

If you need help naming your shapes, check out Example 8.7 (under
Examples by Chapter) on my site: http://www.PowerfulPowerPoint.com/

--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/
 
K

Keith

Hi Bill,
Thanks very much. I'm about to try all the ideas that you and David
suggested. Can't wait! This will make a fun presentation for an otherwise
serious group.
Keith
 
K

Keith

Hi David,
Thanks very much. I'm about to try all the ideas that you and Bill
suggested. Can't wait! This will make a fun presentation for an otherwise
serious group.
Keith
 

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