title: Using the Word Selection object from an excel macro
body: <p>I am writing a macro in Excel that opens and manipulates a Word document. The code works when I run it through the vba editor in word but when I import the lines of code into my excel macro I get a run-time 438 error.</p>
  
  <p>Word Macro</p>
  
  <pre><code>Selection.Collapse WdCollapseDirection.wdCollapseEnd
  </code></pre>
  
  <p>Code inserted into Excel macro, with wtemp being the word document object</p>
  
  <pre><code>wtemp.Activate
  wtemp.Tables(3).Select
  wtemp.Activate
  wtemp.Selection.Collapse WdCollapseDirection.wdCollapseEnd
  </code></pre>
  
  <p>I believe the issue lies with the selection object, or that I am missing a reference. The references that I have included in VBAProject are:</p>
  
  <ul>
  <li>Visual Basic for Application</li>
  <li>Microsoft Excel 16.0 Objects Library</li>
  <li>OLE Automation</li>
  <li>Microsoft Office 16.0 Office Library</li>
  <li>Microsoft Word 16.0 Office Library</li>
  <li>Microsoft Forms 2.0 Object Library</li>
  <li>Microsoft Scripting Runtime</li>
  </ul>