Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-09-2018, 10:58 AM
slaycock slaycock is offline Macro to highlight unused definitions and undefined terms Windows 7 64bit Macro to highlight unused definitions and undefined terms Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

There's always a niggle.

I cut and pasted the test text back into my word document to ensure that the smart quotes came out right. As a consequence I had two copies of the text in my document.

The code then promptly fell over as I'd forgotten to add a test for duplicate definitions.

You will need to replace the subroutine below in place of the equivalent subroutine in the code I initially provided.

Code:
Sub do_actions_for_quoted_text(this_range As Word.range)

    ' Check to see if a definition we have just found already exists
    If quoted_definitions.Exists(this_range.text) Then
        search_doc.Comments.Add range:=this_range, text:="Duplicate definition?"
        Exit Sub
    End If

    If Not this_range.Next(unit:=wdCharacter).text = close_smart_quote Then
        ' comment out the line below if you don't want comments in the document
        search_doc.Comments.Add range:=this_range.Duplicate, text:="Missing closing quote"
        ' Uncomment the next line to add a closing smart quote if one is missing.
        ' this_range.InsertAfter text:=close_smart_quote
    End If
    
    quoted_definitions.Add key:=this_range.text, Item:=True
    
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to highlight unused definitions and undefined terms Macro that deletes unused styles thejollyroger Word VBA 14 12-04-2017 09:00 AM
Macro to highlight unused definitions and undefined terms Best Practice for Indexing Multiple Word Terms and Sub-Terms jhy001 Word 4 11-06-2017 02:08 PM
Macro to highlight unused definitions and undefined terms Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Wild card to highlight capitalised terms? bertietheblue Word 2 02-08-2013 04:44 PM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

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