Removing Underline From Heading 1

N

Non.Atall

Hi everyone,

I'm converting documents to a a new template. On some of my documents,
some of the text in the Heading 1 style is underlined, which is not
part of the formatting of that style.

I'd like to make a macro that looks for text formatted as Heading 1
and if it's underlined, remove the underline.

It seems like it should be a simple thing, but I'm unable to manage
it.

Any help would be greatly appreciated!
 
G

Greg Maxey

You don't need a macro for this but here is one anyway:

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Style = ActiveDocument.Styles("Heading 1")
.Replacement.Font.Underline = wdUnderlineNone
.Execute Replace:=wdReplaceAll
End With
End Sub
 
K

Klaus Linke

<nitpicking><g>

.Replacement.Font.Underline = _
ActiveDocument.Styles(wdStyleHeading1).Font.Underline

would be safer/better... If you want to restore the style defaults, it's
best to reset them explicitly, and not depend on what you think they are?

Regards,
Klaus
 

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