Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
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.
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…

747 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

14 Experts available now in Live!

Get 1:1 Help Now