title: Using Excel VBA, how to search for a specific word and insert comments against that word in a Word document?
body: <p>I am trying to create an excel based tool that reviews Word documents for specific errors. I want this tool to search for a word/sentence and insert a comment against it. I have written a code (please see below) that is able to highlight the word/sentence, however, unable to insert the comment. </p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>Sub Ref_Figs_Tbls()
  
      Dim wdDoc As Object
  
      Set wdDoc = ActiveDocument
  
      With wdDoc
          With .Range
              With .Find
                  .ClearFormatting
                  .Replacement.ClearFormatting
                  .MatchWildcards = True
                  .Wrap = wdFindStop
                  .Text = "Reference source not found"
                  .Replacement.Text = ""
                  .Execute
              End With
  
              Do While .Find.Found = True
  
                  .Select
                  .HighlightColorIndex = wdRed
  
                  .Select
                  Selection.Comments.Add Range:=Selection.Range
                  Selection.TypeText Text:="Cross referencing error"
  
                  .Collapse wdCollapseEnd
                  .Find.Execute
              Loop
          End With
      End With
  
  End Sub
  </code></pre>