Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

underlining text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sarah - 01 Mar 2005 00:43 GMT
I want to underline text and change the colour of the underline.
I am able to underline it but i cannot color it.
Here is my code.

With ActiveDocument.Range.find
   .Text = errortxt
   .MatchWholeWord = True
   .Replacement.Font.Underline = wdUnderlineWavy
   .Replacement.Font.underlinecolor = wdColorRed
   .Execute replace:=wdReplaceAll
End With

if i use activedocument.range.find.font.underlinecolor = wdcolorred after
the with block it just changes the colour of all the underlined text in the
document

What am i doing wrong?
Vince - 01 Mar 2005 04:20 GMT
I don't know why that does not work. In fact, I couldn't even get it to work
in Word's usual Find and Replace box.

But, this works. The code needs to be optimized but will work.

Dim FoundCase As Boolean
Dim DocRange As Range

FoundCase = True

While FoundCase
Set DocRange = ActiveDocument.Range

   With DocRange.Find
       .text = errortxt
       .Font.UnderLine = wdUnderlineNone
       .Execute

       If .Found Then
           DocRange.Select

            Selection.Font.UnderLine = wdUnderlineWavy
            Selection.Font.UnderlineColor = wdColorRed

            FoundCase = True
       Else
           FoundCase = False
       End If

   End With
Wend

> I want to underline text and change the colour of the underline.
> I am able to underline it but i cannot color it.
[quoted text clipped - 13 lines]
>
> What am i doing wrong?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.