前段时间我写了一篇关于这个问题的博客,应该回答你的问题。
http://www.jht.co.uk/access-colour-color-codes/
下面的代码;
Public Function HTMLColour(HTMLCode As String, Optional Red As Variant, _
Optional Green As Variant, Optional Blue As Variant) As Long
On Error GoTo HTMLColour_Error
‘Converts an HTML colour code number to a long interger
‘Also returns the constituent R,G & B components through supplied parameters
Dim intR As Integer, intG As Integer, intB As Integer
Dim strHTML As String
‘Strip # prefix if supplied
If Len(HTMLCode) < 6 Then Exit Function
strHTML = Right(HTMLCode, 6)
‘Extract R, G, B values
intR = CInt(“&H” & Mid(strHTML, 1, 2))
intG = CInt(“&H” & Mid(strHTML, 3, 2))
intB = CInt(“&H” & Mid(strHTML, 5, 2))
‘Return optional parameters
If Not IsMissing(Red) Then Red = intR
If Not IsMissing(Green) Then Green = intG
If Not IsMissing(Blue) Then Blue = intB
‘Convert RGB to Long integer
HTMLColour = RGB(intR, intG, intB)
HTMLColour_Exit:
Exit Function
HTMLColour_Error:
MsgBox Err.Description, vbExclamation, “Function HTMLColour”
Resume HTMLColour_Exit
端功能
希望这有助于。
的可能的复制[?我如何在Excel/VBA RGB颜色的对应的十六进制值(http://stackoverflow.com/questions/6003324/how-do-i-得到最相应 - 己值的-AN-RGB色-在-E xcel-vba) – Andre