Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2016, 11:34 PM
Pankaj Pankaj is offline VBA word macro to highlight a selected text just like a spell checker Windows 7 64bit VBA word macro to highlight a selected text just like a spell checker Office 2016
Novice
VBA word macro to highlight a selected text just like a spell checker
 
Join Date: Oct 2016
Posts: 1
Pankaj is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 10-14-2016, 03:48 AM
gmayor's Avatar
gmayor gmayor is offline VBA word macro to highlight a selected text just like a spell checker Windows 10 VBA word macro to highlight a selected text just like a spell checker Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
Reply

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
VBA word macro to highlight a selected text just like a spell checker Spell checker in Word protected forms Frankwlc Word 3 08-02-2013 12:15 PM
VBA word macro to highlight a selected text just like a spell checker 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
VBA word macro to highlight a selected text just like a spell checker spell checker trouble! kennystringer Word 6 12-28-2011 11:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft