SnTT: Convereting Hex Colors to RGB Values for use in MS Office

With a little help from Theo, I was able create a function to convert colors in hex format to a value that would work in Excel.

Function ConvertRGB(hexcolor As String) As Long
    Dim r As Long, g As Long, b As Long
    
    On Error Goto Errorproc
    
    r = Clng("&H" & Left(hexcolor, 2))
    g = Clng("&H" & Right(Left(hexcolor, 4), 2)) * 256
    b = Clng("&H" & Right(hexcolor, 2)) * 256 * 256
    
    ConvertRGB = r + g + b
    
finish :
    Exit Function
    
Errorproc :
    Call LogError()
    ConvertRGB = 0
    Resume finish
End Function

This function can work on values from Notes Color fields also.  Just be sure to pass the last 6 characters of the value in the field.  This was the last piece of the puzzle I needed to get working before I could release my next version of the ASND Export Facility

<< Previous Document / Next Document >>
    Be the first in the world to comment on this entry!!!
Post A Comment
Subject: (required)
Name: (required)
Email: (required)
Web Site:
Comment:(No HTML - Links will be converted if prefixed http://)

Remember Me?