![]() |
#1
|
|||
|
|||
![]()
Hello
I have uploaded my document. The VBA code that I have come up with currently is this: Sub Underline() 'Declare our variables Dim wrdFind As Find Dim wrdRng As Range Dim wrdDoc As Document 'Grab the active Document Set wrdDoc = Application.ActiveDocument 'define content in this document Set wrdRng = wrdDoc.Content 'Define the Find Object based on the range Set wrdFind = wrdRng.Find 'Define the parameters of our serch With wrdFind 'look for phrase .Text = "HabilitationServices" 'verify the phrase is underlined .MatchCase = False .MatchPhrase = False .MatchWholeWord = True .Font.Underline = False .MatchAllWordForms = True .IgnoreSpace = True .IgnorePunct = True 'Conduct the search if a match it returns TRUE else False SearchResult = .Execute End With 'In this case find Every instance. Do While wrdFind.Execute = True Loop 'If we found it, display it. If SearchResult = True Then 'Change the word to be highlighted wrdRng.HighlightColorIndex = wdRed End If End Sub I am having issues with looping. It doesn't appear to be looping correctly as it only finds the phrase/word once and highlights it if it is not underlined. I also have attached the document Underline Review. This document has a list of all the words/phrases I need to search the document for and verify they are underlined. Is there an easy way to list all of them out on my visual basic? Any help is appreciated. I have come up with the above code so far by just using google. Thank you Megan Hermon |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Kalü | Word VBA | 22 | 04-24-2018 05:35 AM |
![]() |
thudangky | Word | 13 | 12-12-2013 02:22 AM |
How do I find Repeating Words/Phrases? | CCD2016 | PowerPoint | 0 | 12-01-2013 09:37 PM |
![]() |
Wim vd Velden | Word | 1 | 10-02-2012 05:57 AM |
Transferring all the underlined words | swemhsut | Word | 0 | 08-20-2010 01:34 AM |