title: Creating Tabstops in VBA in Excel for a Word file
body: <p>I need to insert two different text parts automatically into a newly generated file through an Excel Macro. This is an example of my code that I have.</p>
  
  <p>First I clear allthe existing tabs to have a clean document, then I want to put "This text should be aligned on the left" aligned to the left and "This text should be aligned on the right" aligned to the right on the same line.</p>
  
  <pre><code>.Content.Paragraphs.TabStops.ClearAll
  .Content.InsertAfter "This text should be aligned on the left"
  
  .Content.Paragraphs.TabStops.Add Position:=NewPos, _
        Alignment:=wdAlignTabRight, _
        Leader:=wdTabLeaderLines
  
   .Content.InsertAfter "This text should be aligned on the right"
   .Content.InsertParagraphAfter
  </code></pre>
  
  <p>With this command I manage to generate a Tabstop in Word, but I don't seem able to position it, or to make "This text should be aligned on the right" align to the right.</p>
  
  <p>In the end it should look like this:</p>
  
  <p>The two text parts should be generated by VBA and aligned this way.</p>
  
  <p><img src="https://i.stack.imgur.com/V2bWq.png" alt="picture"></p>