Public Function TranslateRGB(ByVal RGB As Long) As OLE_COLOR
'--- Parameter
' [In]
' RGB: an RGB colour value where the low order bytes
' are in red, green, blue order
'--- Return value
' returns the equivalent OLE_COLOR value where the low
' order bytes are in blue, green, red order
Dim pstrRed As String
Dim pstrGreen As String
Dim pstrBlue As String
'Extract the three colour bytes
pstrRed = Hex$((RGB And &HFF0000) / &H10000)
pstrGreen = Hex$((RGB And &HFF00&) / &H100)
pstrBlue = Hex$(RGB And &HFF&)
TranslateRGB = "&H2" & pstrBlue & pstrGreen & pstrRed
End Function