Remove underline from portion of a string

User avatar
Poppadon56
NewLounger
Posts: 9
Joined: 09 Feb 2014, 18:10
Location: Orleans, Ontario, Canada

Remove underline from portion of a string

Post by Poppadon56 »

I've just converted 10,000 documents from Lotus WordPro to MS Word 2003.

One of the problems I encountered was underlining of text in some cases.

From my code, an input textbox form prompts for the string to change. Below has the underline in between the two words and I want to remove the underline where there are spaces. It doesn't show on here but there are about 10 underlined spaces between the words.

Attribute Value


I can remove all of the underline with the code below;

With rngStory.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = strSearch
.Replacement.Text = strReplace
.Wrap = wdFindContinue
If .Replacement.Font.Underline = wdUnderlineSingle Then
'Remove underline from text
.Replacement.Font.Underline = wdUnderlineNone
End If

.Execute Replace:=wdReplaceAll

But I only want to remove it for the spaces like;

Attribute Value

How can I do this?

Thanks,

Don

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Remove underline from portion of a string

Post by HansV »

Welcome to Eileen's Lounge!

Try

.Replacement.Font.Underline = wdUnderlineWords
Best wishes,
Hans

User avatar
Poppadon56
NewLounger
Posts: 9
Joined: 09 Feb 2014, 18:10
Location: Orleans, Ontario, Canada

Re: Remove underline from portion of a string

Post by Poppadon56 »

Exactly what I needed.

Thanks