## Problems modify character style ##

W

Wai

Product: MS Word 2002 (English version)
when I try to change the formatting of the character
style, some problems occur:
- can't change back some options into "default"
(eg for "font size" option, I would like to leave it
blank, soo "font size" will not be changed when I apply
this style)


Optnios which can't changed back into "default":
- font color
- underline style
- underline color
- emphasis mark
- character spaciing | spacing
- character spaciing | position

How to do?
 
C

Cindy M -WordMVP-

Hi Wai,
- can't change back some options into "default"
(eg for "font size" option, I would like to leave it
blank, soo "font size" will not be changed when I apply
this style)
In this case, try going into the Format/Font dialog box and
there *delete* the entry for the font size
- font color: Set to "Automatic"
- underline style: Set to "none"
- underline color: Set to "Automatic"
- emphasis mark: No idea what you mean
- character spaciing | spacing: set to "normal"
- character spaciing | position: set to "Normal"


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
:)
 
K

Klaus Linke

- can't change back some options into "default"

Cindy M -WordMVP- said:
Hi Wai,

In this case, try going into the Format/Font dialog box and
there *delete* the entry for the font size


Hi Cindy & Wai,

Won't work for me.

See your other thread in .application.errors for a clumsy work-around (=
create a character style with the same name, but without the size
definition, in another doc or template. Then copy it with the styles
organizer into your doc).

Regards,
Klaus
 
C

Cindy M -WordMVP-

Hi Klaus,
Hi Cindy & Wai,

Won't work for me.
That's interesting. Worked fine for me. Both when I tested it
after reading John McGhie's contribution for the Profibuch
(2002), and when I tested it again before posting my answer
(2003). But you do have to be in the Format/Font DIALOG Box in
Style modification mode. You can't use the tools on the main
dialog box.

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 :)
 
K

Klaus Linke

Hi Cindy,

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.

Regards,
Klaus
 
C

Cindy M -WordMVP-

Hi Klaus,
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).
Did you read my entire reply. I answered each and every point Wai brought
up, and for color it was to set it to "Automatic".

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 :)
 
K

Klaus Linke

For example, once you have defined a color in the character style,
Cindy M -WordMVP- said:
Did you read my entire reply. I answered each and every point Wai brought
up, and for color it was to set it to "Automatic".


Hi Cindy,

I probably read it, and probably ignored it, because it doesn't work for me,
neither in Word2002 nor in Word2003.
- font color: Set to "Automatic"

Then the character style's definition reads:
.... + color: Auto.

If that character style is used in a paragraph with a red paragraph style,
it will make the text black.
That is not the same as a character style that doesn't have a color in the
definition (and leaves the color red).

Same with all your other recommendations.

Regards,
Klaus
 
C

Cindy M -WordMVP-

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 :)
 
K

Klaus Linke

Hi Cindy,
1. VBA to modify the style
ActiveDocument.Styles("Char1").Font.Hidden = vbUseDefault

I'd be pretty surprised if VB constants worked here by design.
It seems any positive or negative even number acts the same as wdToggle
(9999998).
vbUseDefault happens to evaluate to -2.
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.

Yes, those "True/False" settings aren't really a problem.
I don't find any way to reset any numerical settings (color, size),
nor for font name.

Well, glad it didn't turn out that I was simply too stupid :p

I agree with all the rest of what you wrote, though I'm not versed enough in
OO programming to wholly divine the sense it might make from that viewpoint.

It seems to me that a consistent way to specify the "inherited" value is
missing.

wdUndefined just appears if you have text with mixed formatting.
It doesn't appear, say, for .Style.Font.Hidden if the style doesn't define
the .Hidden property, but takes it from the base style, or (in a character
style) from the underlying paragraph style.

What would be needed would be a new constant -- say wdInherit.

Greetings,
Klaus
 
C

Cindy M -WordMVP-

Hi Klaus,
It seems to me that a consistent way to specify the "inherited" value is
missing.

What would be needed would be a new constant -- say wdInherit.
Agreed. "Wish" it?

Cindy
 

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