Solved

word change text color to blue in words with all caps

Posted on 2014-01-08
3
459 Views
Last Modified: 2014-01-08
I don't work in Word VBA so I am having trouble.

I have a large document whereby I am trying to iterate through the document and find all words that are in all caps format and change the font color to blue.  I have tried a couple for each loops but nothing I can find will stick.

This is simple and not working.

Public Sub AllCapsToBlue()

  Dim doc As Document

   Set doc = ActiveDocument
   
 For Each eword In doc.Range.Words
   
      If eword.Font.AllCaps = True Then
     
       eword.Font.ColorIndex = wdDarkBlue
           
   End If
   
 Next eword
End Sub
0
Comment
Question by:gwarcher
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

Maybe what you want is to change in blue all the capitalized words

and not the ones with the Format AllCaps

pls try

Public Sub AllCapsToBlue()

Dim doc As Document
Set doc = ActiveDocument

For Each eword In doc.Range.Words
    If eword.Text = UCase(eword.Text) Then
        eword.Font.ColorIndex = wdDarkBlue
    End If
Next eword
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:gwarcher
Comment Utility
perfect, thanks!
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
This can be done without a macro by specifying the font formatting, but here is a macro version:
Sub BlueCaps()
    With ActiveDocument.Range.Find
        .Font.AllCaps = True
        .Replacement.Font.Color = wdColorBlue
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Outlook Free & Paid Tools
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now