title: Why won't Excel VBA won't find and replace in Word document
body: <p>I'm fairly new to VBA, trying to fill out a word template from Excel with VBA in Excel. I'm using the following code to put in the Date into a tag in the word document:
   Dim Template As String</p>
  
  <pre><code>Dim WordDoc, WordApp As Object
  Dim Template as String
  On Error Resume Next                                                      
  Set WordApp = GetObject("Word.Application")                                 
  If Err.Number &lt;&gt; 0 Then                                                     
      Err.Clear                                                               
      Set WordApp = CreateObject("Word.Application")                          
      WordApp.Visible = True                                                  
  End If
  Template = "C:\Users\me\Dropbox\me - Summer 2019\RMA_Log\00059-001_E_24May19_Form Returned Authorization.docx"
  Set WordDoc = WordApp.Documents.Open(FileName:=Template, ReadOnly:=False)
  With WordDoc.Content.Find                                                   
      .Text = "&lt;Date&gt;"                                                        
      .Replacement.Text = "06-06-2019"                                        
      .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue                                     
  End With
  </code></pre>
  
  <p>But this won't replace any text in the main body of my word document.</p>
  
  <p>I've tried doing <code>WordDoc.ActiveDocument.Content.Find</code> but that also doesn't work.  If I copy the code exactly and replace <code>WordDoc</code> with <code>ActiveDocument</code> and run it in word VBA, the text gets replaced.  </p>
  
  <pre><code>Dim Template As String
  Template = "C:\Users\me\Dropbox\me - Summer 2019\RMA_Log\00059-001_E_24May19_Form Returned Authorization.docx"
  
  With ActiveDocument.Content.Find                                                   
      .Text = "&lt;Date&gt;"                                                        
      .Replacement.Text = "06-06-2019"                                        
      .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue                                     
  End With
  </code></pre>
  
  <p>If I run this code in Word VBA, it replaces the  Tag, why wouldn't it work to run this from Excel?</p>
  
  <p>Edit: Office 2016</p>