![]() |
What is the RGB value of the colour of Excel's scroll bars
Hi NG. We have surrounded an Excel scroll bar with cells coloured grey
(RGB(240,240,240) - but it's not a precise match. Does any on know the RGB value of the scroll bars ? Thanks Charles |
What is the RGB value of the colour of Excel's scroll bars
It appears to be 236,233,216
I found this by putting a scrollbar on a userform and running the sub test, which I've reproduced below in case you need to check other colours. Private Declare Function TranslateColor Lib "olepro32.dll" _ Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _ ByVal palet As Long, col As Long) As Long Sub test() Dim RealColor As Long, test As OLE_COLOR test = UserForm1.ScrollBar1.BackColor TranslateColor test, 0, RealColor MsgBox "The backcolor of this form is R=" & _ CStr(RealColor And &HFF&) & " G=" & _ CStr((RealColor And &HFF00&) / 2 ^ 8) & _ " B=" + CStr((RealColor And &HFF0000) / 2 ^ 16) End Sub Charles Jordan wrote: Hi NG. We have surrounded an Excel scroll bar with cells coloured grey (RGB(240,240,240) - but it's not a precise match. Does any on know the RGB value of the scroll bars ? Thanks Charles |
What is the RGB value of the colour of Excel's scroll bars
Steve Garman wrote in message ...
It appears to be 236,233,216 I found this by putting a scrollbar on a userform and running the sub test, which I've reproduced below in case you need to check other colours. Private Declare Function TranslateColor Lib "olepro32.dll" _ Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _ ByVal palet As Long, col As Long) As Long Sub test() Dim RealColor As Long, test As OLE_COLOR test = UserForm1.ScrollBar1.BackColor TranslateColor test, 0, RealColor MsgBox "The backcolor of this form is R=" & _ CStr(RealColor And &HFF&) & " G=" & _ CStr((RealColor And &HFF00&) / 2 ^ 8) & _ " B=" + CStr((RealColor And &HFF0000) / 2 ^ 16) End Sub Charles Jordan wrote: Hi NG. We have surrounded an Excel scroll bar with cells coloured grey (RGB(240,240,240) - but it's not a precise match. Does any on know the RGB value of the scroll bars ? Thanks Charles Thanks Steve - for accuracy, promptness, replying on a Sunday ..and a very scientific solution. Charles |
What is the RGB value of the colour of Excel's scroll bars
This code should work for any location on the screen:
Option Explicit Private Declare Sub Sleep _ Lib "kernel32" _ (ByVal dwMilliseconds As Long) Private Declare Function GetCursorPos _ Lib "user32" _ (lpPoint As POINTAPI) As Long Private Declare Function GetPixel _ Lib "gdi32" _ (ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long) As Long Private Declare Function GetDC _ Lib "user32" _ (ByVal hwnd As Long) As Long Private Type POINTAPI x As Long y As Long End Type Public Sub ColorUnderCursor() Dim pCursorPos As POINTAPI Dim lngColorUnderCursor As Long Dim R As Long Dim G As Long Dim B As Long ' Sleep two seconds to allow cursor ' to move somewhere useful Sleep 2000 GetCursorPos pCursorPos lngColorUnderCursor = _ GetPixel(GetDC(0&), _ pCursorPos.x, pCursorPos.y) SplitRGB lngColorUnderCursor, R, G, B MsgBox CStr(lngColorUnderCursor) & _ ":" & vbCrLf & _ "R=" & CStr(R) & vbCrLf & _ "G=" & CStr(G) & vbCrLf & _ "B=" & CStr(B) End Sub Sub SplitRGB( _ ByVal RGBValue As Long, _ ByRef R As Long, _ ByRef G As Long, _ ByRef B As Long _ ) R = RGBValue And 255 G = RGBValue \ 256 And 255 B = RGBValue \ 256 ^ 2 And 255 End Sub |
What is the RGB value of the colour of Excel's scroll bars
|
What is the RGB value of the colour of Excel's scroll bars
|
All times are GMT +1. The time now is 02:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com