title: How can I find and replace text in Word using Excel VBA?
body: <p>I am using Excel VBA to open a document in Word. Once the document is open the goal is to search for "InsuranceCompanyName" and replace it with the company's name. </p>
  
  <p>I have tried </p>
  
  <pre><code>wordDoc.Find.Execute FindText:="InsuranceCompanyName", ReplaceWith:="Fake Ins Co"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>wordDoc.Replace What:="InsuranceCompanyName", Replacement:="Fake Ins Co"
  </code></pre>
  
  <p>and also </p>
  
  <pre><code>For Each myStoryRange In ActiveDocument.StoryRanges
  
      With myStoryRange.Find
          .Text = "InsuranceCompanyName"
          .Replacement.Text = "Fake Ins Co"
          .WrapText = wdFindContinue
          .Execute Replace:=wdReplaceAll
      End With 
  Next myStoryRange
  </code></pre>
  
  <p>The full code is listed below. </p>
  
  <pre><code>Sub FindReplace()
  
  Dim wordApp As Object 
  Dim wordDoc As Object 
  Dim myStoryRange As Range
  
  'sets up the word app
  Set wordApp = CreateObject("Word.Application")
  wordApp.Visible = True 
  
  'opens the document that we need to search through 
  Set wordDoc = wordDoc = wordApp.Documents.Open("C:\Users\cd\LEQdoc.docx")
  
  'here is where the find and replace code would go
  
  End Sub 
  </code></pre>
  
  <p>For the first method I get the error:</p>
  
  <blockquote>
    <p>Object doesn't support this property or method. </p>
  </blockquote>
  
  <p>For the second: the same error</p>
  
  <p>The third method:</p>
  
  <blockquote>
    <p>argument not optional</p>
  </blockquote>
  
  <p>in regards to the .Find in </p>
  
  <pre><code>With myStoryRange.Find
  </code></pre>