Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-22-2022, 10:24 AM
Mehermon Mehermon is offline Word VBA find over 50 words/phrases and verify they are underlined. Windows 10 Word VBA find over 50 words/phrases and verify they are underlined. Office 2021
Novice
Word VBA find over 50 words/phrases and verify they are underlined.
 
Join Date: Nov 2022
Posts: 4
Mehermon is on a distinguished road
Default Word VBA find over 50 words/phrases and verify they are underlined.

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA find over 50 words/phrases and verify they are underlined. VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters Kalü Word VBA 22 04-24-2018 05:35 AM
Word VBA find over 50 words/phrases and verify they are underlined. How to mark underlined words in a sentence as A, B, C, D (beneath the words) 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
Word VBA find over 50 words/phrases and verify they are underlined. Almost all words underlined by Word. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:11 AM.


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