Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2014, 03:34 AM
JSC6 JSC6 is offline Highlight Words from a Word List Windows 8 Highlight Words from a Word List Office 2013
Novice
Highlight Words from a Word List
 
Join Date: Sep 2014
Posts: 1
JSC6 is on a distinguished road
Post Highlight Words from a Word List

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 would really like this to work for Word 2013. Could you guys help me?

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
Reply With Quote
  #2  
Old 09-30-2014, 08:22 PM
macropod's Avatar
macropod macropod is offline Highlight Words from a Word List Windows 7 64bit Highlight Words from a Word List Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight Words from a Word List Find and highlight multiple words in MS Word document AtaLoss Word VBA 37 09-22-2021 12:04 PM
Highlight Words from a Word List 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
Highlight Words from a Word List 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 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