How to remove italic formatting

K

Klaus Linke

I'm obviously a bloody beginner in Word.

I have some text, some of it formatted in the (italic) character style
"Emphasis", some of it with "italic" applied as manual formatting.

I want to have all the text formatted "not italic".

Selection.Font.Italic=False
does not work.

Am I overlooking an obvious, simple solution, or do I have to write some
elaborate code, just to remove the italic formatting?

Regards,
Klaus
 
G

Graham Mayor

Curious. I formatted some text with manual italics, some more with an italic
character style and yet more with italic paragraph style
Selection.Font.Italic=False removed all the italics?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

Klaus Linke

Hi Graham,

Heureka, a compassionate soul to put me out of my misery!

I'm obviously a bloody newsgroup newbie, too: Word2003.

And unfortunately, it still does not work.
Selection.Font.Italic=False
Italic is removed from the text formatted as italic manually, but stays for
the text formatted in the character style "Emphasis".

Weirdly enough, I could swear it happened the other way around half an hour
ago...
Ah, yes: If more than half the characters in the selection are in the
character style, it *does* happen the other way around.

The text I used was "Text Emphasis italic more text", with "Emphasis"
formatted in the style of that name, and "italic" made italic.

Selection.Font.Italic=True
applies italic to normal text, removes italic from the character style, and
leaves manual italic alone.

I started Word in safe mode, but no change.

Baffled,
Klaus
 
K

Klaus Linke

More weirdness: What happens depends also on what is applied to the first
character in the selection.
And sometimes Selection.Font.Italic=False makes normal text (no character
style) italic.

That really does not seem to be normal, and happens in all documents...
I'll try to recreate the Word registry entries.

Klaus
 
K

Klaus Linke

A repair installation didn't help, and I see the same problem on another
machine.

As another test:
-- In some arbitrary text, type "eit".
-- Apply the Emphasis style to "e", italic to "i".
-- Select "eit"
-- Run Selection.Font.Italic=False
"e" isn't italic any more, "i" stays italic, "t" turns italic.

I am at my wit's end, and give up for now...
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :
A repair installation didn't help, and I see the same problem on
another machine.

As another test:
-- In some arbitrary text, type "eit".
-- Apply the Emphasis style to "e", italic to "i".
-- Select "eit"
-- Run Selection.Font.Italic=False
"e" isn't italic any more, "i" stays italic, "t" turns italic.

I am at my wit's end, and give up for now...
Klaus

Have you tried using
Selection.Font.Reset
on all characters that have a Character style applied to them before using
Selection.Font.Italic=False
???

It will slow down the code, but if you know you will only have short
selections, then it will not matter too much.

Of course, you could use it in one fell swoop, but it will remove all font
formatting that is not dictated by the underlying paragraph style... It
maybe more than what you want.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

Salut,

I need to keep the character styles. I take it you don't see the problem
either, like Graham?

Klaus
 
G

Graham Mayor

The plot thickens :)

Using your exact example the e remains in italic? However if you use

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Font.Italic = True
.Replacement.Font.Italic = False
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll

Both are changed - go figure?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

Klaus Linke

Great idea... and it works!
Strangely again, if I do the same replacement from the user interface, it
leaves the "e" italic.

I'm leaving for the weekend, thank you very much! That solution should be a
lot faster than removing the italic character by character.

Weird... you think you know a bit about the program, and then something
simple like this turns out a nightmare.

Regards,
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :
Salut,

I need to keep the character styles. I take it you don't see the
problem either, like Graham?

I did not test it, because I know if both of you have seen it, this is
enough for me, also, I know that if you start working with manual formatting
and style formatting, problems/complications eventually arise.

I suggested the .Font.reset because it occurs to me that if you apply a
character style whose whole purpose is to make some characters italicised,
and then you need to remove the italic, than the character style has no
reason for being anymore and should not be kept. Working against character
style is difficult and not logical, in my view anyways.
Of course, you would need to test for the name of the character style and
reset only the one that sets the currently selected character to italic.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

Graham Mayor was telling us:
Graham Mayor nous racontait que :
The plot thickens :)

Using your exact example the e remains in italic? However if you use

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Font.Italic = True
.Replacement.Font.Italic = False
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll

Both are changed - go figure?

Great idea, Find/Replace always does stuff that is difficult to replicate by
code.

By the way, you should remove
Selection.HomeKey Unit:=wdStory
or the code will remove italic in the whole document.

Also, this is a behaviour that is linked to the fact that you are using
character styles, not with italic itself. You can see the same thing if you
use Bold and the Strong character style.

The only thing I am not comfortable with this method is that you re left
with character style in the document that do not do their jobs, i.e. you
have the Emphasis style applied to some characters, but those are not
italic. This can create problems later when doing further/different
formatting.


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

The only thing I am not comfortable with this method is that you re left
with character style in the document that do not do their jobs, i.e. you
have the Emphasis style applied to some characters, but those are not
italic. This can create problems later when doing further/different
formatting.


Hi Jean-Guy,

The purpose of styles is semantic mark-up. It's about the meaning of text,
not the formatting.
And there are lots of cases in my experience when it makes sense to apply
other (manual) formatting on top.

I don't see why Word should show rather arbitrary/random behaviour when you
use .Font.Italic=False on some text that has been formatted with styles. It
should simply set Italic to False.

That it does not seems to me a rather ugly bug.

Regards,
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :
Hi Jean-Guy,

The purpose of styles is semantic mark-up. It's about the meaning of
text, not the formatting.

I don't get it. Do you mean that styles in gereral have only a semantic
purpose, not a formatting one?
I do not think that this is what you mean.
Styles *are* about formatting.
I guess what you meant is that in your particular case you needed a style to
act as a semantic marker.

If you need a style for semantic mark-up, a character styles seems
appropriate, but you should not use one that applies italic, and then try
to remove it... just create a style that does not have a visual impact and
use that.
And there are lots of cases in my experience when it makes sense to
apply other (manual) formatting on top.

Agreed.
But what I meant was that if you leave behind a style that is supposed to
apply an italic format, but that does not, it may create problems down the
line.
This is different from applying a style that should make something italic,
and then you manually add underlining, or make the font bigger... If you do
not need the italic anymore, the character style whose sole job is to apply
italic should be removed. At least, this makes sense to me... But I am a bit
weird, I'll admit that!
I don't see why Word should show rather arbitrary/random behaviour
when you use .Font.Italic=False on some text that has been formatted
with styles. It should simply set Italic to False.

I totally agree. That line of code should work, regardless of the styles
applied tot he current selection.
That it does not seems to me a rather ugly bug.

Indeed.


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

The purpose of styles is semantic mark-up. It's about the meaning of
I don't get it. Do you mean that styles in gereral have only a semantic
purpose, not a formatting one?
I do not think that this is what you mean.

That is exactly what I mean.
If something is formatted as "Heading 1" or "Emphasis", it says something
about the meaning, not about the font size or line spacing.

Regards,
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :
That is exactly what I mean.
If something is formatted as "Heading 1" or "Emphasis", it says
something about the meaning, not about the font size or line spacing.

Ha! I see what you mean.
The name of the style is indicative of its purpose, but still, the primary
goal of all styles (in Word) is to affect the visual aspect of the
characters/paragraphs they are applied to.

So, if you apply Emphasis, which also applies Italic besides tagging a
meta-text value to a range of text, and then remove the Italic, when you
view or print the document, you will never know where that Emphasis style
was applied, rendering the application of that style kind of useless. This
is why I think the visual aspect is more important because you could call
that Emphasis style whatever you want, and the visual result would be the
same. Isn't what Word is designed for... viewing/printing documents? In
other words, the name of the style helps the user choose the appropriate
style according to the type of range the style is going to be applied to, so
the name of the style hs iportance, but main the reason the style is being
applied is not merely to assign a tag, the style changes the format.

I guess I have difficulty imagining a scenario where the name of the style
is more important than the actual impact that style has on text. I have
never seen anyone apply style just to indicate a meta-text meaning to a
range of text without that style also having an impact on the visual aspect.
The only case where I would see this being done is if someone was setting up
a regular document to be converted in XML where the styles would be
indicative of the XML tags to create. Here the styles would not have any
need to change the visual format because they would be used to create XML
tags and/or the XML Schema.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Helmut Weber

Hi Jean-Guy,
I have never seen anyone apply style just
to indicate a meta-text meaning to a
range of text without that style also
having an impact on the visual aspect.

haven't seen me yet. ;-)

I sometimes found it annoying, that there can't be two paragraph
styles identical in all aspects but the name, like it is
possible in Quark Xpress, if I recall correctly.

So I had to change one irrelevant property of a style
in order to get two almost equal styles.

Can't remember, though, what it was good for.

Cheers,

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jean-Guy Marcil

Helmut Weber was telling us:
Helmut Weber nous racontait que :
Hi Jean-Guy,


haven't seen me yet. ;-)

lol
What I meant was that it is not very common to use styles for meta
purposes...
I sometimes found it annoying, that there can't be two paragraph
styles identical in all aspects but the name, like it is
possible in Quark Xpress, if I recall correctly.

So I had to change one irrelevant property of a style
in order to get two almost equal styles.


I am not sure I understand..
Sure, you can have two identical styles in all aspects but the name...

What do you mean?


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Helmut Weber

Hi Jean-Guy,
I am not sure I understand..
Sure, you can have two identical styles
in all aspects but the name...

You understand perfectly well.

Yes, with Word 2003 here and now it is possible.
Was it always that way?

I seem to remember times, when Word told me,
that a style like then one i was trying to create,
was already existing.

Well, don't bother, live is a long song.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jean-Guy Marcil

Helmut Weber was telling us:
Helmut Weber nous racontait que :
Hi Jean-Guy,


You understand perfectly well.

Yes, with Word 2003 here and now it is possible.
Was it always that way?

As far as I now, but I must confess I have never tried to create two
identical styles!
I am not that twisted!
I seem to remember times, when Word told me,
that a style like then one i was trying to create,
was already existing.

Well, don't bother, live is a long song.

Cheers!

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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