Styles

L

LEU

When I convert documents my styles are as follows:

Level 1
Level 1 + Underline

Level 2
Level 2 + Underline

and so on.

How do I make them all just Level 1, Level 2 and so on? If I record a macro
using Find and Replace, it does not work the next time I use it. It does not
see the difference between Level 1 and Level 1 + Underline. This is what it
records:

Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Level 1")
Selection.Find.Replacement.ClearFormatting
Selction.Find.Replacement.Style = ActiveDocument.Styles("Level 1")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
 
J

Jay Freedman

The "styles" that include the + sign aren't really styles at all. They're what
Word shows when the option Tools > Options > Edit > Keep track of formatting is
turned on, and direct formatting is applied on top of a paragraph style.

You can prevent the display of the "+" pseudo-styles by turning off the
aforementioned option.

If you want to find text that has both the paragraph style and the direct
formatting, you have to specify both in the .Find setup. You can do that in the
recorder by, for instance, setting the Find What box in the Replace dialog to
include style "Level 1" and (most easily by pressing Ctrl+U) the underline
direct formatting; and setting the Replace With box to "Level 1" and (by
pressing Ctrl+U twice) the "no underline" direct formatting. However, because of
a bug in the macro recorder that remained unfixed through Word 2003, this will
work only in Word 2007. See
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm for details.

If you just want to modify the code you already have, then add these lines
somewhere inside the With clause:

.Font.Underline = wdUnderlineSingle
.Replacement.Font.Underline = wdUnderlineNone

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 
L

LEU

THat worked. Thanks Jay.



Jay Freedman said:
The "styles" that include the + sign aren't really styles at all. They're what
Word shows when the option Tools > Options > Edit > Keep track of formatting is
turned on, and direct formatting is applied on top of a paragraph style.

You can prevent the display of the "+" pseudo-styles by turning off the
aforementioned option.

If you want to find text that has both the paragraph style and the direct
formatting, you have to specify both in the .Find setup. You can do that in the
recorder by, for instance, setting the Find What box in the Replace dialog to
include style "Level 1" and (most easily by pressing Ctrl+U) the underline
direct formatting; and setting the Replace With box to "Level 1" and (by
pressing Ctrl+U twice) the "no underline" direct formatting. However, because of
a bug in the macro recorder that remained unfixed through Word 2003, this will
work only in Word 2007. See
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm for details.

If you just want to modify the code you already have, then add these lines
somewhere inside the With clause:

.Font.Underline = wdUnderlineSingle
.Replacement.Font.Underline = wdUnderlineNone

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 

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