title: VBA Using Excel 2016 to Populate Word 2016 Content Controls
body: <p>I'm attempting to populate a Word.dotm document that has content control text boxes using Excel. </p>
  
  <p>In Excel, I create the word objects and open the file, but I can't figure out how to actually access the controls. </p>
  
  <p>In the Word doc's VBA, I can access them via </p>
  
  <p><code>.SelectContentControlsByTitle("control").Item(1).Range.Text = "..."</code> </p>
  
  <p>but that doesn't work using an Object in Excel..</p>
  
  <p>Here's the code I've tried in Excel:</p>
  
  <pre><code>Dim objWord         As Object
  Dim objDoc          As Object
  Dim objSelection    As Object
  Dim ctrl            As Word.ContentControl
  
  Set objWord = CreateObject("Word.Application")
  
  Set objDoc = objWord.Documents.Add(ThisWorkbook.Path &amp; "\MyDoc.dotm")
  
  objWord.Visible = True
  
  Set objSelection = objWord.Selection
  
  'Doesn't work
  objDoc.SelectContentControlsByTitle("control").Item(1).Range.Text = "..."        
  
  'Doesn't work either, but tried nonetheless
  For Each ctrl In objDoc.contentcontrols
      If ctrl.Title = "control" Then
          ctrl.Range.Text = "!"
          Exit For
      End If
   Next ctrl
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I didn't have the MS Word 16.0 Object Library referenced... the early binding and the tip to copy the template file rather than altering it directly mentioned by Timothy Rylatt now works and John Korchok's For Each loop works as well. Their additions have been added to the code above. Thank you!</p>