Hi Klaus,
OK, I've had some time to follow up on this
1. VBA to modify the style
ActiveDocument.Styles("Char1").Font.Hidden = vbUseDefault
The definition will still show "Not hidden", but the character style will
comply to the setting of the underlying paragraph. I assume the same should
apply to the other "True/False" settings.
I don't find any way to reset any numerical settings (color, size), nor for
font name. I think the problem we're seeing here is how the properties are set
for the class. Either the property is not set, or, once it's set, it will only
accept a "correct" value (string or number within a certain range). There's no
way to "uninitialize" it through the VB interface. Apparently the
Style/Format/Font dialog box *can* do this. From an VBA-OO-standpoint, this
makes a certain amount of sense. In this case, I think you'd have to approach
the problem by renaming the style, creating a new style of the "correct" name,
then applying the style attributes you want to maintain
Dim sty As Word.Style
Application.OrganizerRename "Document3", "Char3", "CharTemp",
wdOrganizerObjectStyles
Set sty = ActiveDocument.Styles.Add("Char3", wdStyleTypeCharacter)
With sty
sty.BaseStyle = ""
sty.Font.Size = ActiveDocument.Styles("CharTemp").Font.Size
End With
Then use Find/Replace to apply the newly created style.
2. I see what you mean about the color. I was looking at in applied in a
paragraph that used "automatic".
If I follow your instructions, it still doesn't work for me in Word2002, but
it does in Word2003.
I'd also consider it a bug that you have to use the sub-menu.
In either version, you'll still get problems with other character
formatting.
For example, once you have defined a color in the character style, you can
only change it to some other color, but you can't get rid of the color
altogether (since you can't "clear" the color in the submenu like you can
the font size).
I haven't figured out an easy way to clear the font size from the style
definition from VBA, either.
The macro recorder doesn't record anything useful, even in the versions
where your method works.
ActiveDocument.Styles("TestCharStyle").Font.Size = wdUndefined
does nothing.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail