Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default command button color

is there a way to refer to the color of the button as simply "red..." rather
than: &H8000000F& (it's a bit cryptic)

as always, thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default command button color

If in VBA, use the pre-defined color constants or, if not available, define
your own.

Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If CommandButton1.BackColor < vbRed Then
CommandButton1.BackColor = vbRed
CommandButton1.ForeColor = vbBlack
Else
CommandButton1.BackColor = vbBlack
CommandButton1.ForeColor = vbRed
End If
End Sub

Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

Const clrRed = &HFF&
Const clrBlack = &H80000012

If CommandButton1.BackColor < clrRed Then
CommandButton1.BackColor = clrRed
CommandButton1.ForeColor = clrBlack
Else
CommandButton1.BackColor = clrBlack
CommandButton1.ForeColor = clrRed
End If
End Sub

You can define constants in a procedure, or in the declaration section (at
the top) of a module, either private or public, depending on the scope (how
widely available among your code) that you need.

"mark kubicki" wrote in message
...
is there a way to refer to the color of the button as simply "red..."

rather
than: &H8000000F& (it's a bit cryptic)

as always, thanks in advance




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
change the face color of an Excel command button Chris Leah Excel Discussion (Misc queries) 5 April 21st 23 09:03 AM
Change color of command button dhstein Excel Discussion (Misc queries) 1 May 21st 09 01:08 AM
color fill button is not adding color to my spread sheet mitchnmd Excel Worksheet Functions 1 September 26th 07 04:36 PM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 10:47 AM.

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"