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

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,508
Office Version
2010
Platform
Windows
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
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,717
Office Version
2010
Platform
Windows
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.
 

GrumpyOldGit

New Member
Joined
Jun 28, 2012
Messages
13
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.
 

Forum statistics

Threads
1,082,278
Messages
5,364,201
Members
400,786
Latest member
ismi88

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top