Solved

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

Posted on 2014-04-01
2
1,373 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
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…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

786 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