Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2021, 03:35 AM
laith93 laith93 is offline Highlight words in a table that does not exist in current document Windows 10 Highlight words in a table that does not exist in current document Office 2019
Competent Performer
Highlight words in a table that does not exist in current document
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
The macro checks each of your listed abbreviations in the table against the document and highlights them. This would then allow you to look through the document to establish which items are not highlighted and therefore missing from the table.
Excuse me Mr. gmayor, I think you still do not understand me. To clarify, suppose AAA is an abbreviation and was written in the table and present in paragraph 5 of my document. Also, suppose paragraph 5 was deleted by the supervisor, the abbreviation in paragraph 5 was gone, but still present in the table. According to your idea for the code, it will highlight already existed abbreviations in the paragraphs, but what about abbreviations that have been deleted in the deleted paragraphs. As a consequence, I don't know which abbreviations were deleted, as the code highlight only existed abbreviations. In conclusion, highlighting unused abbreviations in the table is an ideal way for rapidly recognizing deleted abbreviations.

However, I faced this problem when running your code:
143.png

Furthermore, during waiting time I googled and found this code from
HTML Code:
https://wordribbon.tips.net/T001173_Highlight_Words_from_a_Word_List.html
, which is similar to your 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
In the same way, the problem with this code is highlighting the existed abbreviations in the active document, so if you can modify it to highlight unused abbreviations in the checklist file only. Also, according to the above code, I found an article that highlights the words in both documents:

HTML Code:
https://stackoverflow.com/questions/49292384/highlight-words-microsoft-word-from-checklist-and-highlight-matching-words-in-c
Thank you again
Reply With Quote
Reply

Tags
word vba, word vba code, word vba highlight text



Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight words in a table that does not exist in current document Find and highlight multiple words in MS Word document AtaLoss Word VBA 37 09-22-2021 12:04 PM
How to redact words listed in one document from the current document AlanofBayCourt Word VBA 0 10-31-2019 03:00 AM
Find and highlight multiple words in MS Word document qkjack Word VBA 7 02-21-2018 07:09 PM
Highlight words in a table that does not exist in current document Using VBA to Compare and Highlight words in a Word Table's Row/Cell KeithLee22 Word VBA 2 11-11-2015 03:37 PM
Find and highlight multiple words in a document flatop Word VBA 3 04-16-2014 10:29 PM

Other Forums: Access Forums

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