In PowerPoint is there a way of setting up a mouse over function

G

Guest

Hi Everyone,
With some serious searching over the net I have come up with an example that
I think answers my questions. I found the solution here:
http://skp.mvps.org/ppt00049.htm
It comes with a sample PowerPoint presentation to show the VB code in action.
While being new to VB, I can work out most of what's going in this
particular script in that the order in which the text boxes are drawn is
important for this particular example. The first text box, Case 1 acts to
hide the text that is revealed by mousing over text boxes 2 - 8. It sits
behind the other boxes so that as soon as the mouse leaves text boxes 2-8 it
is automatically over and activating text box 1 which then hides any visible
text. What I haven't been able to work out is how/where the VB script tells
text box 8 (Case 8) to display the messages activated by the text box (case)
2-8 mouseovers. Perhaps for this type of function, the last drawn text box is
always the one that displays the result?
Thanks in anticipation.
 
S

Steve Rindsberg

Hi Everyone,
With some serious searching over the net I have come up with an example that
I think answers my questions. I found the solution here:
http://skp.mvps.org/ppt00049.htm
It comes with a sample PowerPoint presentation to show the VB code in action.
While being new to VB, I can work out most of what's going in this
particular script in that the order in which the text boxes are drawn is
important for this particular example. The first text box, Case 1 acts to
hide the text that is revealed by mousing over text boxes 2 - 8. It sits
behind the other boxes so that as soon as the mouse leaves text boxes 2-8 it
is automatically over and activating text box 1 which then hides any visible
text. What I haven't been able to work out is how/where the VB script tells
text box 8 (Case 8) to display the messages activated by the text box (case)
2-8 mouseovers.

The code in question is posted below. After each Case, you see the line:

.Text = "whatever"

Since the whole thing is within the context of

With SlideShowWindows(1).View.Slide _
.Shapes(8).TextFrame.TextRange

...

End With

the .Text in question is the text range of Shape 8.

Sub DisplayMessage(oShp As Shape)
' Ascertain the position of the mouse by checking the
' index value of shape over which the mouse rests.
With SlideShowWindows(1).View.Slide _
.Shapes(8).TextFrame.TextRange
Select Case oShp.ZOrderPosition
' The purple rectangle on which the buttons rest
' we use the event here to clear the existing message while
' the mouse moves to the next shape
Case 1
.Text = ""
Case 2
.Text = "Descriptive Message when mouse moves over Shape 2"
Case 3
.Text = "Descriptive Message when mouse moves over Shape 3"
Case 4
.Text = "Descriptive Message when mouse moves over Shape 4"
Case 5
.Text = "Descriptive Message when mouse moves over Shape 5"
Case 6
.Text = "Descriptive Message when mouse moves over Shape 6"
Case 7
.Text = "Descriptive Message when mouse moves over Shape 7"
Case 8
.Text = "Descriptive Message when mouse moves over Shape 8"
End Select
DoEvents
End With
End Sub



Perhaps for this type of function, the last drawn text box is
 
G

Guest

Hi Steve,
Thanks for your response. Apologies for my delayed response due to being
offsite on a live in course.
With respect to your advice on:
With SlideShowWindows(1).View.Slide _
.Shapes(8).TextFrame.TextRange

I had incorrectly interpreted '.Shapes(8)' as being the number of shapes
involved in the VBScript, however it apparantly refers to number/name of the
actual shape. So I assume if it was '.Shapes(6)' the mouseover text would
appear in Shape (6).
I tried cutting and pasting all of the shapes to the Master to see if they
would work there. In 'Show' mode the hyperlinks work but the mouseover
function no longer works. Does the script need to be changed somehow so that
the mouseover function works if it resides on the master page.
Thanks again for your assistance.
Chris
 
S

Steve Rindsberg

Hi Steve,
Thanks for your response. Apologies for my delayed response due to being
offsite on a live in course.
With respect to your advice on:


I had incorrectly interpreted '.Shapes(8)' as being the number of shapes
involved in the VBScript, however it apparantly refers to number/name of the
actual shape.

That's correct.

Shapes(8) refers to the shape with Index value of 8 or in human, the eighth shape on
the slide (press tab repeatedly to cycle through the shapes in index order)

Shapes("Some name") refers to the shape named "Some name"
I tried cutting and pasting all of the shapes to the Master to see if they
would work there. In 'Show' mode the hyperlinks work but the mouseover
function no longer works. Does the script need to be changed somehow so that
the mouseover function works if it resides on the master page.

Depending on the script, yes. That is, if you copy Shape 8 from a slide to the master,
it's unlikely that it'll still be Shape 8 on the master. You'd need to adjust for the
fact that there are different shapes so different numbers on the master.
 
G

Guest

(I've posted this in two topic areas as both relate to the same project. This
is probably the most appropriate place to carry this converstaion forward)

OK this is where I have got to.

Thanks to your suggestions about checking the shape identifier numbers on
the master slide, as they are most likely different to what they are/were on
the presentation slide, I have been able to make the mouseover action work on
buttons placed on the master slide, except... For some reason the mouseover
action will only return a result in a shape on a presentation slide and not a
master slide.
For example, if I start with a new blank presentation and draw 6 mouseover
buttons/shapes and one result textbox/shape and insert the following code:

Sub DisplayMessage(oShp As Shape)
' ascertain the position of the mouse by checking the
' index value of shape over which the mouse rests.
With SlideShowWindows(1).View.Slide _
.Shapes(7).TextFrame.TextRange
Select Case oShp.ZOrderPosition
' The purple rectangle on which the buttons rest
' we use the event here to clear the existing message while
' the mouse moves to the next shape

Case 1
.Text = "Metro"
Case 2
.Text = "Projects"
Case 3
.Text = "Process"
Case 4
.Text = "Finishes"
Case 5
.Text = "Technical"
Case 6
.Text = "Misc"


End Select
DoEvents
End With
End Sub

Mousing over any of the button/shapes/case in 'Show' mode will return the
appropriate text in the text/rectangle/shape 7.

If I copy all the shapes to the master page, assuming it is completely
empty, and position the shapes at a different place on the slide, the pasted
shapes on the master slide have exactly the same identifier numbers as the
corresponding shapes on the presentation slide. So all of the VB script is
still applicable.

When I go to 'Show' mode, if I mouse over the buttons/shapes that were
placed on the presentation slide, they return a result in the
text/rectangle/shape 7 sitting on the presentation slide. If I mouseover the
buttons/shapes that were placed on the master slide they will also return a
result, however the result is returned in the text/rectangle/shape7 that is
sitting on the presentation slide and not the text/rectangle/shape7 that is
sitting on the master page. Even if I create a shape 8 on the master slide
and change the VB script to suit, I still can't get a result showing up in a
text/rectangle shape sitting on the master slide.

Frustrating, as I need all these buttons on master slides as my project
requires around 100 slides between several linked presentations. So you can
see I'm trying to keep things simple and a smaller file size by trying to
work with the master page for the buttons.

Looking at the VB script again, I'm wondering if the key lies in the lines:
With SlideShowWindows(1).View.Slide _
.Shapes(7).TextFrame.TextRange

Are the words 'With SlideShowWindows(1).View.Slide _' telling PowerPoint to
look at the presentation slide to return the result in shape 7 rather than
returning the result in shape 7 on the master page. If this is the case, is
there an alternate script to tell PowerPoint to look at the master page for
shape 7 in which to display the result.

I have also tried adding another VB module for the shapes on the master
slide but PowerPoint only wants to return a result in shape 7 on the
presentation slide.

Again I really appreciate your help and this eventual solution will be used
in all my followup presentations.

Regards

Chris
 
S

Steve Rindsberg

(I've posted this in two topic areas as both relate to the same project. This
is probably the most appropriate place to carry this converstaion forward)

OK this is where I have got to.

Thanks to your suggestions about checking the shape identifier numbers on
the master slide, as they are most likely different to what they are/were on
the presentation slide, I have been able to make the mouseover action work on
buttons placed on the master slide, except... For some reason the mouseover
action will only return a result in a shape on a presentation slide and not a
master slide.
For example, if I start with a new blank presentation and draw 6 mouseover
buttons/shapes and one result textbox/shape and insert the following code:

Sub DisplayMessage(oShp As Shape)
' ascertain the position of the mouse by checking the
' index value of shape over which the mouse rests.
With SlideShowWindows(1).View.Slide _
.Shapes(7).TextFrame.TextRange
Select Case oShp.ZOrderPosition
' The purple rectangle on which the buttons rest
' we use the event here to clear the existing message while
' the mouse moves to the next shape

Case 1
.Text = "Metro"
Case 2
.Text = "Projects"
Case 3
.Text = "Process"
Case 4
.Text = "Finishes"
Case 5
.Text = "Technical"
Case 6
.Text = "Misc"


End Select
DoEvents
End With
End Sub

Mousing over any of the button/shapes/case in 'Show' mode will return the
appropriate text in the text/rectangle/shape 7.

If I copy all the shapes to the master page, assuming it is completely
empty, and position the shapes at a different place on the slide, the pasted
shapes on the master slide have exactly the same identifier numbers as the
corresponding shapes on the presentation slide. So all of the VB script is
still applicable.

When I go to 'Show' mode, if I mouse over the buttons/shapes that were
placed on the presentation slide, they return a result in the
text/rectangle/shape 7 sitting on the presentation slide. If I mouseover the
buttons/shapes that were placed on the master slide they will also return a
result, however the result is returned in the text/rectangle/shape7 that is
sitting on the presentation slide and not the text/rectangle/shape7 that is
sitting on the master page. Even if I create a shape 8 on the master slide
and change the VB script to suit, I still can't get a result showing up in a
text/rectangle shape sitting on the master slide.


Because the whole thing takes place within the context of this:

With SlideShowWindows(1).View.Slide _
.Shapes(7).TextFrame.TextRange

.... stuff

End with

Change it to

With SlideShowWindows(1).View.SlideMaster _
.Shape etc etc etc

And if you're going to be using this a lot, it might be more reliable to take the time to
name each of the shapes rather than relying on index order.

Sub DisplayMessage(oShp As Shape)
' The shape's .Parent will be either the slide or master
' it's on; this way you don't have to worry which
With oShp.Parent.Shapes("Target").TextFrame.TextRange
.Text = oShp.Name
DoEvents
End With
End Sub

Make each shape's .Name the text you want to display in the box and you're in business.
If you need to use long names, I wouldn't rely on this, but there's another fairly simple
way of doing it with .Tags.
 
G

Guest

To Steve, David, John and Luc,
What can I say?
I am indebted to you all for working with me and getting me over the line
with a fully functioning mouseover action in PowerPoint, just like they have
in Dreamweaver and Flash!
In the end Steve provided a simple piece of VB script that works both on
normal presentation and master slides.
The renaming 'addin' just topped it off by swapping changeable PowerPoint
shape references to meaningful names.
It makes you wonder why Microsoft just sits on its hands with this
application when, with a little thought, it could really be a very powerful
piece of multimedia software. Although I have to admit that latest version is
vastly improved on previous iterations.
I really feel privlidged to have had all of your assistance in this.
Having this action with greatly simplify and enhance my presentations and
will do away with a lot of those hidden workarounds that you often have to
devise to 'fake' a certain look. I also have to admit I will enjoy watching
my colleagues trying to figure out how in the heck that mouseover works as
they are not even aware of the VB backdoor.
Once again, my sincere appreciation to you all,

Chris

PS I'm going to have to get a copy of David's book.
 
S

Steve Rindsberg

What can I say?

You said it. said:
It makes you wonder why Microsoft just sits on its hands with this
application when, with a little thought, it could really be a very powerful
piece of multimedia software.

Well, it's like this. There's no way they could build in all the features that you want, and
that I want and that Bill wants and that every otherbody who uses it wants.

So instead they toss in this nifty Erector Set thingie called VBA so we can build our own, or
other people can custom-build stuff for us. It's more work than just getting what we want out
of the box in the first place, but the odds of getting what we want, one way or the other, are
MUCH better.
 

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