...Or mouse-over VB code?

J

Justin

Two follow ups to my question about mouse-over color change

1. Is there a way to set the "default" color that the action function
changes the object color too in action settings > mouseover > highlight
(even though it only lasts for 1 second it's better than nothing.

2. OR ideally, does anyone know if there is a VB code for this function
(changing color of a vector object -- or inserting an identical different
colored object over it -- on mouse over)

Thanks all.

Justin

ORIGINAL QUESTION: ok I thought I knew how to do this....apparently not.

I'm using PowerPoint 2003 and I want to change the color of an object when I
mouse-over it in slideshow mode. similar to the html function.
unfortunately the only opton is in action settings where it "highlights" it
to some default color is there mouse over function where I can change the
color of a box from one color to another and it return to the original color
when I move the mouse away? I thought you could do that in PowerPoint.

any help much appreciated

thanks all

Justin
 
G

Guest

Justin,

Here is some VB code that will change the color of an object for 1 second
when your mouse goes over. You can pick the originating and changed color you
want with the RGB numbers. Of course, you'll have to adjust the object number
to your specific object.

Let me know if it does good for you.

Sub Wait()
waitTime = 1
Start = Timer
While Timer < Start + waitTime
DoEvents
Wend
End Sub

Sub ChangeColor()
ActivePresentation.SlideShowWindow.View.Slide.Shapes("Rectangle
8").Fill.ForeColor.RGB = _
RGB(191, 204, 254)
Wait
ActivePresentation.SlideShowWindow.View.Slide.Shapes("Rectangle
8").Fill.ForeColor.RGB = _
RGB(191, 150, 200)
End Sub
 
D

David M. Marcovitz

VBA can change the color on Mouse Over. The difficulty is to change it
back when the mouse is no longer over the object. This could be done by
putting another object around the object to be changed that has a mouse
over function to change the first object back. To change an object on
MouseOver, assign the following macro to the Mouse Over action setting
for that object:

Sub ChangeColor(oShp As Shape)
oShp.Fill.ForeColor.RGB = RGB(0, 0, 1000)
End Sub

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

David M. Marcovitz

This is good. Combine it with my more simplistic answer, and you've got a
great solution. Instead of needing the specific shape use oShp by making
the Sub line the following

Sub ChangeColor(oShp As Shape)

Then, instead of ActivePresentation.View.Slide.Shapes(....), just use
oShp.

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

Hi Steve,

I'm new to VBA and I am unsure where to put the codes I have to enter in the
declaration section of the module.... basically, I have no clue what the
declaration section of a module is! I'd like to try out the sleep command but
can't seem to do it.

Can you help me with this?

Thanks!
 
S

Steve Rindsberg

Hi Steve,

I'm new to VBA and I am unsure where to put the codes I have to enter in the
declaration section of the module.... basically, I have no clue what the
declaration section of a module is! I'd like to try out the sleep command but
can't seem to do it.

The declarations sectino of a module is the part at the very top, BEFORE any Sub or
Function definitions.

So your whole module might look like:

Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Wait()
waitTime = 1
Sleep(waitTime * 1000)
End Sub

... and so on
 
G

Guest

Uhmmm... I must be doing somehting wrong as the shape is not changing color
after a second. This is the code I've put in... You see anything wrong with
it?

Thanks for your patience!

Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Wait()
waitTime = 1
Sleep (waitTime * 1000)
End Sub

Sub ChangeColor(oShp As Shape)
oShp.Fill.ForeColor.RGB = RGB(100, 204, 254)
Wait
oShp.Fill.ForeColor.RGB = RGB(1, 150, 200)
End Sub
 
G

Guest

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Wait()
waitTime = 1
Sleep (waitTime * 1000)
End Sub


Sub ChangeColor(oShp As Shape)
oShp.Fill.ForeColor.RGB = RGB(100, 204, 254)
'extra bit!
DoEvents
Wait
oShp.Fill.ForeColor.RGB = RGB(1, 150, 200)
End Sub
--
Did that answer the question / help?
___________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
 
G

Guest

John,

This line never kicks in... as if it's waiting forever?
oShp.Fill.ForeColor.RGB = RGB(1, 150, 200)
 
S

Steve Rindsberg

Uhmmm... I must be doing somehting wrong as the shape is not changing color
after a second. This is the code I've put in... You see anything wrong with
it?

Thanks for your patience!

No problem. My version included Option Explicit (which forces you to declare all
variables, a generally good idea, but which caused an error since waittime wasn't
declared). It's a good idea to choose Debug, Compile before running any code. That'll
point you at a lot of errors right away. Saves hair. <G>

======================================================
Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Wait()
Dim waittime As Long
waittime = 1
Sleep (waittime * 1000)
End Sub

Sub ChangeColor(oShp As Shape)
oShp.Fill.ForeColor.RGB = RGB(100, 204, 254)
Wait
oShp.Fill.ForeColor.RGB = RGB(1, 150, 200)
End Sub

======================================================
 
G

Guest

Thanks to both of you! I reduced the wait time and made it go through the
motion twice. I get a perfect flash effect!
 

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