![]() |
|
#1
|
|||
|
|||
|
Hi everyone!
I'm trying to create a macro for Microsoft Word 2013. However, it does not work. Here is the code: Code:
Sub CompareWordList()
Dim sCheckDoc As String
Dim docRef As Document
Dim docCurrent As Document
Dim wrdRef As Object
sCheckDoc = "C:\checklist.doc"
Set docCurrent = Selection.Document
Set docRef = Documents.Open(sCheckDoc)
docCurrent.Activate
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Bold = True
.Replacement.Text = "^&"
.Forward = True
.Format = True
.MatchWholeWord = True
.MatchCase = True
.MatchWildcards = False
End With
For Each wrdRef In docRef.Words
If Asc(Left(wrdRef, 1)) > 32 Then
With Selection.Find
.Wrap = wdFindContinue
.Text = wrdRef
.Execute Replace:=wdReplaceAll
End With
End If
Next wrdRef
docRef.Close
docCurrent.Activate
End Sub
I found it on the following link, where it says it works for 2007 and 2010 only: http://wordribbon.tips.net/T001173_H...Word_List.html Last edited by macropod; 09-30-2014 at 08:20 PM. Reason: Added code tags & formatting |
|
#2
|
||||
|
||||
|
That code should work with any Word version. There is nothing in it that isn't generic to every version from Word 95 to Word 2013.
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find and highlight multiple words in MS Word document
|
AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
Macro to highlight a list of words
|
bakerkr | Word VBA | 4 | 10-19-2017 02:23 PM |
| Adapt a script used in Word to highlight words, to work in Outlook? | flatop | Outlook | 5 | 07-15-2014 01:07 PM |
Using macros to highlight worksheet words referenced in external list/doc.
|
Daniel_NYC | Word VBA | 1 | 04-21-2014 03:35 PM |
| permanently highlight searched words in word 2013 | arjay | Word | 4 | 08-16-2013 09:29 AM |