#1
|
|||
|
|||
VBA word macro to highlight a selected text just like a spell checker
I used the below code to count the no. of words in sentences. If no. of words is greater than 20 then it should highlight it. I used the below code. It's just coloring the background. I want to just highlight it just like spell checker. please help.
Code: Sub Count_of_words() ' ' Count Macro ' ' Dim s As Range For Each s In Selection.Sentences If s.Words.count > 20 Then s.HighlightColorIndex = wdYellow Next End Sub |
#2
|
||||
|
||||
Highlight colours the background. That's all that it does. There is no facility in Word to add coloured wiggly underlines as highlights.
I suppose you could add a coloured wiggly underline font characteristic e.g. Code:
Sub Count_of_words() Dim s As Range For Each s In Selection.Sentences If s.Words.Count > 20 Then With s.Font .Underline = wdUnderlineWavy .UnderlineColor = wdColorDarkYellow End With End If Next End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
word vba, word vba highlight text, word vba macro |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Spell checker problem! | KEMYST | Word | 2 | 12-29-2014 04:57 AM |
Spell checker in Word protected forms | Frankwlc | Word | 3 | 08-02-2013 12:15 PM |
Macro to highlight text between 2 points in word 2010 | jsilva1950 | Word VBA | 2 | 04-25-2013 12:21 AM |
Spell checker keeps getting disabled | Jennifer Murphy | Word | 0 | 03-08-2012 06:20 AM |
spell checker trouble! | kennystringer | Word | 6 | 12-28-2011 11:41 AM |