View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson[_4_] Greg Wilson[_4_] is offline
external usenet poster
 
Posts: 218
Default Highlight Button...

The code works for me when the 3 labels are the only ones
on the sheet. The code was intended for illustrative
purposes only and is thus highly simplified. The code must
be pasted to the code module belonging to the worksheet
involved - not a standard module. If other labels existed
on the sheet before these 3 were added then the numbering
will be wrong.

Q1: Are you sure you added LABELS from the Control Toolbox
toolbar? Click on each of the labels while in design mode
and check to see what its name is in the name box of the
Formula Bar. To activate design mode, activate the upper-
left button of the Control Toolbox toolbar.

Q2: Are you sure you pasted the code to the code module
belonging to the sheet involved?

Q3: What error message does it give you?

Regards,
Greg


-----Original Message-----
Thanks, Greg. This is very helpful. I'm getting an error

on the 7th line from
the bottom:

Set OleObj = Me.OLEObjects("Label" & i)

....any idea what could be causing this?

Thanks,
EU


"Greg Wilson" wrote:

The only way you can do this to my knowledge is to use
controls from the Control Tollbox toolbar and exploit

the
MouseMove event supported by these controls. Suggested

is
that you initially add one label from this toolbar and

do
the following:

1) Right-click the label.
2) Select Properties from the popup menu.
3) Format the TextAlign property to fmTextAlignCenter.
4) Format the ForeColor property to whatever you like.
5) Change the Caption to whatever's appropriate.
(Note: Don't worry about the special effect propery -

the
appended code will take care of this).
6) Close the Properties menu and right-click the label
again.
7) Select Copy.
8) Paste two copies of the label to the worksheet.
9) Go back into the Properties menu and change the
captions of these new labels to whatever you want.
10) Position the labels as required.
11) Unselect the Design Mode control at the top-left
corner of the Control Toolbox toolbar and close the
toolbar.
12) Paste the below code to the worksheet code module.


Private Sub Label1_MouseMove(ByVal Button As Integer,
ByVal Shift As Integer, ByVal X As Single, ByVal Y As
Single)
Normalize
Label1.BackColor = 16777164
Label1.SpecialEffect = fmSpecialEffectSunken
'Do whatever else . . .
End Sub
Private Sub Label2_MouseMove(ByVal Button As Integer,
ByVal Shift As Integer, ByVal X As Single, ByVal Y As
Single)
Normalize
Label2.BackColor = 16777164
Label2.SpecialEffect = fmSpecialEffectSunken
'Do whatever else . . .
End Sub
Private Sub Label3_MouseMove(ByVal Button As Integer,
ByVal Shift As Integer, ByVal X As Single, ByVal Y As
Single)
Normalize
Label3.BackColor = 16777164
Label3.SpecialEffect = fmSpecialEffectSunken
'Do whatever else . . .
End Sub
Private Sub Normalize()
Dim i As Long, OleObj As OLEObject
For i = 1 To 3
Set OleObj = Me.OLEObjects("Label" & i)
With OleObj.Object
.SpecialEffect = fmSpecialEffectRaised
.BackColor = vbMenuBar
End With
Next
End Sub

Regards,
Greg


-----Original Message-----
I created a database in Excel and attached buttons to

control macros. No
problem. I'd like to add code that will change the

appearance of the buttons
from raised to sunken when the cursor/pointer moves

over
them, like in html
app's.

What code can I add to do this, and where should it go

(standard module,
etc...).

I always stress function over form, however, this tool

is
going to senior
management so I want to make it look as "professional"

as
possible.

Thanks for your help.

EU
.


.