Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Highlight Button...

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
.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
.


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to highlight more related cells if cell highlight Jon Excel Discussion (Misc queries) 5 December 21st 08 01:06 PM
using option button to highlight cells Carl Excel Worksheet Functions 0 June 5th 06 06:48 PM
Highlight cells with ctrl-click but only un-highlight one cell hagan Excel Discussion (Misc queries) 5 May 27th 05 06:45 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM


All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"