Not pretty but it works:
<SNIP>
With .Font
<SNIP>
Select Case .Color
Case wdColorGray05
StylesArray(7, StyleCount) = "5% Grey"
Case wdColorGray10
StylesArray(7, StyleCount) = "10% Grey"
Case wdColorGray125
StylesArray(7, StyleCount) = "12.5% Grey"
Case wdColorGray15
StylesArray(7, StyleCount) = "15% Grey"
Case wdColorGray20
StylesArray(7, StyleCount) = "20% Grey"
Case wdColorGray30
StylesArray(7, StyleCount) = "30% Grey"
Case wdColorGray35
StylesArray(7, StyleCount) = "35% Grey"
Case wdColorGray375
StylesArray(7, StyleCount) = "37.5% Grey"
Case wdColorGray40
StylesArray(7, StyleCount) = "40% Grey"
Case wdColorGray45
StylesArray(7, StyleCount) = "45% Grey"
Case wdColorGray50
StylesArray(7, StyleCount) = "50% Grey"
Case wdColorGray55
StylesArray(7, StyleCount) = "55% Grey"
Case wdColorGray60
StylesArray(7, StyleCount) = "60% Grey"
Case wdColorGray625
StylesArray(7, StyleCount) = "62.5% Grey"
Case wdColorGray65
StylesArray(7, StyleCount) = "65% Grey"
Case wdColorGray70
StylesArray(7, StyleCount) = "70% Grey"
Case wdColorGray75
StylesArray(7, StyleCount) = "75% Grey"
Case wdColorGray85
StylesArray(7, StyleCount) = "85% Grey"
Case wdColorGray90
StylesArray(7, StyleCount) = "90% Grey"
Case wdColorGray80
StylesArray(7, StyleCount) = "80% Grey"
Case wdColorGray875
StylesArray(7, StyleCount) = "87.5% Grey"
Case wdColorGray95
StylesArray(7, StyleCount) = "95% Grey"
Case wdColorIndigo
StylesArray(7, StyleCount) = "Indigo"
Case wdColorLightBlue
StylesArray(7, StyleCount) = "Light Blue"
Case wdColorLightOrange
StylesArray(7, StyleCount) = "Light Orange"
Case wdColorLightYellow
StylesArray(7, StyleCount) = "Light Yellow"
Case wdColorOliveGreen
StylesArray(7, StyleCount) = "Olive Green"
Case wdColorPaleBlue
StylesArray(7, StyleCount) = "Pale Blue"
Case wdColorPlum
StylesArray(7, StyleCount) = "Plum"
Case wdColorRed
StylesArray(7, StyleCount) = "Red"
Case wdColorRose
StylesArray(7, StyleCount) = "Rose"
Case wdColorSeaGreen
StylesArray(7, StyleCount) = "Sea Green"
Case wdColorSkyBlue
StylesArray(7, StyleCount) = "Sky Blue"
Case wdColorTan
StylesArray(7, StyleCount) = "Tan"
Case wdColorTurquoise
StylesArray(7, StyleCount) = "Turquoise"
Case wdColorViolet
StylesArray(7, StyleCount) = "Violet"
Case wdColorWhite
StylesArray(7, StyleCount) = "White"
Case wdColorYellow
StylesArray(7, StyleCount) = "Yellow"
Case wdColorAqua
StylesArray(7, StyleCount) = "Aqua"
Case wdColorAutomatic
StylesArray(7, StyleCount) = "Automatic"
Case wdColorBlack
StylesArray(7, StyleCount) = "Black"
Case wdColorBlue
StylesArray(7, StyleCount) = "Blue"
Case wdColorBlueGray
StylesArray(7, StyleCount) = "Blue Grey"
Case wdColorBrightGreen
StylesArray(7, StyleCount) = "Bright Green"
Case wdColorBrown
StylesArray(7, StyleCount) = "Brown"
Case wdColorDarkBlue
StylesArray(7, StyleCount) = "Dark Blue"
Case wdColorDarkGreen
StylesArray(7, StyleCount) = "Dark Green"
Case wdColorDarkRed
StylesArray(7, StyleCount) = "Dark Red"
Case wdColorDarkTeal
StylesArray(7, StyleCount) = "Dark Teal"
Case wdColorDarkYellow
StylesArray(7, StyleCount) = "Dark Yellow"
Case wdColorGold
StylesArray(7, StyleCount) = "Gold"
Case wdColorGreen
StylesArray(7, StyleCount) = "Green"
Case wdColorLavender
StylesArray(7, StyleCount) = "Lavender"
Case wdColorLightGreen
StylesArray(7, StyleCount) = "Light Green"
Case wdColorLightTurquoise
StylesArray(7, StyleCount) = "Light Turquoise"
Case wdColorLime
StylesArray(7, StyleCount) = "Lime"
Case wdColorOrange
StylesArray(7, StyleCount) = "Orange"
Case wdColorPink
StylesArray(7, StyleCount) = "Pink"
Case Else
StylesArray(7, StyleCount) = "Custom"
End Select
End With
<SNIP>
This behind a UserForm that collects the various data points about the InUse
styles and uses the style NameLocal as values in a ComboBox. All of the date
points get displayed in related TextBoxes on the UserForm when the user
selects a style from the ComboBox and clicks a button.
Partial code:
Private Sub btnViewDetails_Click()
Dim Idx As Integer
Idx = cboStylesList.ListIndex
<SNIP>
txtFontColour.Value = StylesArray(7, Idx)
<SNIP>
End Sub
Also has code to print this info in a new doc.
Note that this is very much a WIP, so don't pay too much attention to the
details. I'm just trying to work out how to collect the info at this point; I
figure out what to do with it later.
Anyway, thanks for pointing me in the right direction. I was hoping it would
be simple but I had a feeling it might be something like this.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
macropod said:
Hi Gordon,
If you look up ColorIndex in Word's help file, you'll see a list of the standard colour set (WdColorIndex constants). In theory, you
should be able to use this test whether the selected font's colour is in the colorindex, via something like:
Sub FontColourTest()
Dim col As String
Select Case Selection.Characters(1).Font.ColorIndex
Case 0
col = "wdAuto"
Case 1
col = "wdBlack"
Case 2
col = "wdBlue"
Case 3
col = "wdTurquoise"
Case 4
col = "wdBrightGreen"
Case 5
col = "wdPink"
Case 6
col = "wdRed"
Case 7
col = "wdYellow"
Case 8
col = "wdWhite"
Case 9
col = "wdDarkBlue"
Case 10
col = "wdTeal"
Case 11
col = "wdGreen"
Case 12
col = "wdViolet"
Case 13
col = "wdDarkRed"
Case 14
col = "wdDarkYellow"
Case 15
col = "wdGray50"
Case 16
col = "wdGray25"
Case Else
col = vbCrLf & "not in the Word ColorIndex"
End Select
MsgBox "The first selected character's colour is " & col
End Sub
However, in Word 2000 at least, I get false matches between the colours shown on the standard font palette and the colorindex (eg
'Tan' is returned as 'wdYellow'). This also happens with custom colours.
Note that the above code can't return a meaningful colour is characters
--
Cheers
macropod
[MVP - Microsoft Word]
Gordon Bentley-Mix said:
G'day!
I'm working on a little tool that presents key information about the styles
in a document in a more user-friendly format. One of the data points I want
to provide is the font colour. I've read heaps about changing the colour of
various things - bits of text, graphs, even fonts - but I haven't seen
anything about determining what the colour of a font is currently. If I use
the value of the .Color property of the Font object, it gives me _really_
useful things like: -16777216 for Automatic; 255 for Red; 16711680 for Blue;
etc. Unfortunately, I don't think too many of my users are going to
understand this. <g>
Is there an easy way to "translate" the .Color values into something that a
wetware-based system can make sense of? I'd be happy with just the wdColor
constants and show anything else as "Custom".
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.