Hex v RGB in a Form's Properties Window

GrumpyOldGit

New Member
Joined
Jun 28, 2012
Messages
13
Hi Guys....

I'm trying to find the RGB value for a standard Excel 2010 colour - the grey background colour for a Form.
When I look in the Properties window, it's specified as "&H8000000F&".
Assuming the "&"s are field delimiters, and "H" indicates Hexadecimal, the Hex value is 80 00 00 0F.
I seem to have one too many characters!
How do I "convert" the value specified in the Form's properties window into an RGB code (and vice versa)?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The leading "8" in that hex number tells Windows it's a "system color"... those are (or at least can be) set individually by the user (that is, they can differ from computer to computer). VB reads the computer's display properties settings to get them. Here is some code to return the RGB color for the various system colors, but note the argument is a code for the particular system item and not a standard hex number...

Code:
Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
 
Public Enum Colour_Constants
    COLOR_SCROLLBAR = 0
    COLOR_BACKGROUND = 1
    COLOR_ACTIVE_CAPTION = 2
    COLOR_INACTIVE_CAPTION = 3
    COLOR_MENU = 4
    COLOR_WINDOW = 5
    COLOR_WINDOWFRAME = 6
    COLOR_MENU_TEXT = 7
    COLOR_WINDOW_TEXT = 8
    COLOR_CAPTION_TEXT = 9
    COLOR_ACTIVE_BORDER = 10
    COLOR_INACTIVE_BORDER = 11
    COLOR_APP_WORKSPACE = 12
    COLOR_HIGHLIGHT = 13
    COLOR_HIGHLIGHT_TEXT = 14
    COLOR_BUTTON_FACE = 15
    COLOR_BUTTON_SHADOW = 16
    COLOR_GRAY_TEXT = 17
    COLOR_BUTTON_TEXT = 18
    COLOR_INACTIVE_CAPTION_TEXT = 19
    COLOR_BUTTON_HIGHLIGHT = 20
    COLOR_BUTTON_DARK_SHADOW = 21
    COLOR_BUTTON_LIGHT_SHADOW = 22
    COLOR_TOOLTIP_TEXT = 23
    COLOR_TOOLTIP = 24
End Enum
 
Function SystemColorRGB(ColourType As Colour_Constants) As Long
    SystemColorRGB = GetSysColor(ColourType)
End Function
 
Upvote 0
Assuming the "&"s are field delimiters, and "H" indicates Hexadecimal ...
The &H specifies a hex constant, and the trailing & is the type declaration character for a Long.
 
Upvote 0
Thanks Rick!
Not only have you helped me to find a solution to my problem, I've also learned one or two new things by studying and executing your code.
Your MVP status is well deserved!

Also, thanks for the helpful note from shg.
 
Upvote 0

Forum statistics

Threads
1,223,734
Messages
6,174,186
Members
452,550
Latest member
southernsquid2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top