View Single Post
 
Old 01-09-2018, 10:58 AM
slaycock slaycock is offline Windows 7 64bit 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