Solved

VBA - Change Font Color of a Line of Text Based on First non-Blank Character

Posted on 2014-04-01
2
1,363 Views
Last Modified: 2014-04-02
Would appreciate assistance with a WORD VBA routine.

Based on the current selection, change the font color to Green for the entire line of text for any line where the first non-blank character is a tick mark ( ' ).  

I am copying VBA code into a WORD document and want to color the comment lines green in the document.  I am familiar with Excel VBA but have no experience with WORD VBA so the more explicit the better.

Thank You,
Jerry
0
Comment
Question by:Jerry Paladino
2 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 39971418
See if this gives you the results you're looking for:
Sub Color_Rem()
Application.ScreenUpdating = False
With ActiveDocument.Content.Find
  .ClearFormatting
  .Text = " '[!^13]{1,}"
    With .Replacement
      .Text = "^&"
      .ClearFormatting
      .Font.Color = wdColorGreen
    End With
      .Forward = True
      .Wrap = wdFindContinue
      .Format = True
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
  Application.ScreenUpdating = True
End Sub

Open in new window

Flyster
0
 
LVL 16

Author Closing Comment

by:Jerry Paladino
ID: 39971925
Thank you Flyster - Much appreciated.
Jerry
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

920 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

15 Experts available now in Live!

Get 1:1 Help Now