Theme Colors/Long values

G

Greg Maxey

Does anyone know how to covert the Word2007 theme color values to
corresponding long values?

Here is a simplified example of the problem. If you set the shading
of a table cell or row using a theme color, a standard color, or a
custom color (the choices available in the shading dialog) you set a
color value (I think it is 24 bit) to the cell range. Using a the
following line of code if the value was set to a Theme Color the
number is always a negative value. If set to a standard color or
custom color the return is a long value.

Msgbox Selection.Cells(1).Shading.BackgroundColorPattern

I created a blank user form and with this code:

Private Sub UserForm_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim oRow As Row
Set oRow = ActiveDocument.Tables(1).Rows(1)
Me.BackColor = oRow.Shading.BackgroundPatternColor
End Sub


The intent is to set a UserForm control back color to match the
shading in a table row. This code works perfectly in Word2003 and in
2007 provided I don't apply a theme color as the shading.

As soon as I do, the Userform initialize code fails. I know why it
fails but I am looking for a way to convert a theme color value to a
corresponding long value.

Any ideas?
 

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