![]() |
|
#8
|
|||
|
|||
|
As a companion to that function (very useful btw, thanks)
This one converts a VBA colour code to a six character hex code useable in CSS etc. Not sure if the blue and green are wrongly labelled, but the order is correct (it produces the right colour). The Hex function returns "0" rather than "00" so it needs padding. Code:
Private Function fcnLongToHex(ByRef lngColor As Long) As String
Dim hRed, hGreen, hBlue
hRed = Hex(lngColor Mod 256)
If Len(hRed) = 1 Then hRed = "0" & hRed
hGreen = Hex((lngColor \ 256) Mod 256)
If Len(hGreen) = 1 Then hGreen = "0" & hGreen
hBlue = Hex((lngColor \ 256 \ 256) Mod 256)
If Len(hBlue) = 1 Then hBlue = "0" & hBlue
fcnLongToHex = hRed & hBlue & hGreen
End Function
|
| Tags |
| color, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Codes Popping Up In My Text?
|
Faedrie | Word | 1 | 11-08-2012 01:00 AM |
Codes for Word Textbox Font Color?
|
tinfanide | Word VBA | 7 | 10-23-2012 03:13 PM |
Losing VBA codes in .dotm
|
tinfanide | Word VBA | 15 | 04-12-2012 12:39 AM |
Outline Codes
|
eliz.bell | Word | 4 | 03-28-2012 07:27 PM |
| Why run-time is always different from stepping into the codes? | tinfanide | Excel Programming | 1 | 03-04-2012 12:04 AM |