Converting colours to hexadecimal code

L

liddlem

Hi Folks
I am busy writing a macro which will convert an RTF document into
HTML which will be viewed through Flash. (Which means that there is
very limited tag set.)

I have pretty much solved the conversion of the text, but am strugglin
with the color formatting conversion as HTML requires the colours to b
specified in HEX code.

I have tried a "straight" conversion as follows, but the result is no
the same.

MyHexColor = Hex(Selection.Font.Color)

In the case of RED, the hex value that is returned is "FF", but th
text is diplayed as GRAY in the HTML document.

Apparently the correct value should be "FF0000", so I thought tha
maybe the I needed to have a 6 character hex code. No problem - I wrot
this.

MyHexColor = Hex(Selection.Font.Color)
MyHexCntr = 2
If Len(MyHexColor) < 6 Then
MyHexLen = 6 - Len(MyHexColor)
MyHexString = "0"
Do While MyHexCntr <= MyHexLen
MyHexCntr = MyHexCntr + 1
MyHexString = MyHexString & "0"
Loop
MyHexColor = MyHexColor & MyHexString
End If

Still no success.

I have thought about writting a case statement which will conver
wdColor***** to Hex, but cannot seem to find help on how to return th
wdColor(value)

I.E.
MyColour = Selection.Font.Color returns either "Red" or a value lik
"345254".
I would like it to return "wdColourRed" or "wdColourPink"
Then at least, I can map it back to a fixed array of colours.

The question is - Is this the solution? (I.E. I am sure that it i
possible that the text colour is not one of the 60 wdColorxx options?)
:confused:

So ANY idea's would be most welcome.
Thanks :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top