![]() |
|
|
|
#1
|
||||
|
||||
|
Ok, for that quantity of Words I would say stick with your current method (unless you save it as a csv text file). The time consuming part of the macro will probably be the loop itself.
Try these modifications Code:
Sub B2_Highlighter_Selection_andAllWordForms()
Dim FRDoc As Document, FRList() As String, i As Long, aRng As Range
Application.ScreenUpdating = False
Options.DefaultHighlightColorIndex = wdBrightGreen
Set FRDoc = Documents.Open("C:\path.docx", ReadOnly:=True, Addtorecentfiles:=False, Visible:=False)
FRList = Split(FRDoc.Range.Text, vbCr)
FRDoc.Close False
'FRList = Split("Document True Text ClearFormatting", " ") 'for testing only
Set FRDoc = Nothing
Set aRng = Selection.Range
With aRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindStop
.Replacement.Text = "^&"
.Replacement.Highlight = True
For i = 0 To UBound(FRList) 'Process each word from the List
If Trim(FRList(i)) <> "" Then
.Text = Trim(FRList(i))
.Execute Replace:=wdReplaceAll
End If
Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
| Tags |
| find, highlight, macro |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
highlight words not in list
|
karkey | Word VBA | 3 | 01-05-2021 02:13 PM |
Macro To Identify & Highlight Words In MS Word Based Upon A List In Excel File Column
|
abhimanyu | Word VBA | 5 | 03-20-2020 01:33 PM |
| How to find (highlight) two and more words in a list of 75k single words in Word 2010 | Usora | Word | 8 | 05-29-2018 03:34 AM |
Macro to highlight a list of words
|
bakerkr | Word VBA | 4 | 10-19-2017 02:23 PM |
Find and highlight all words ending in -ly
|
RBLampert | Word VBA | 13 | 10-23-2012 04:45 PM |