title: Outlook VBA insert line of text
body: <p>I'm trying to write a piece of code (vba) that inserts a single line in the email i'm composing (open e-mail item). The code below is a first step i took</p>
  
  <p><strong>What works</strong></p>
  
  <ol>
  <li>if I run the code directly from the module (development window), the text is inserted.</li>
  </ol>
  
  <p><strong>What doesn't work</strong></p>
  
  <ol>
  <li>If I add the a macro (vba) in my ribbon and try to run it, nothing happens. The code only seems to work directly form the module (Play button).</li>
  </ol>
  
  <p><strong>What I want</strong></p>
  
  <ol>
  <li><strike>Run macro (vba) from ribbon in active/open item;</strike>
  Solution = A Module name can't contain a Macro of the same name.</li>
  <li>Set font color to e.g. green;</li>
  <li>Nice to have: insert text at bottom of page.</li>
  </ol>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>Sub InsertText()
  Dim sText As String
  
  sText = "Text to insert"
  
  
  On Error GoTo ErrHandler
  If TypeName(ActiveWindow) = "Inspector" Then
      If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
          ActiveInspector.WordEditor.Application.Selection.TypeText sText
      End If
  End If
  Exit Sub
  ErrHandler:
  Beep
  End Sub
  </code></pre>