How to insert text into Outlook email editor using VBA

Solution 1:

InsertBefore Method or InsertAfter Method

Inspector.WordEditor Property (Outlook)

Application.ActiveInspector Method (Outlook)

Example

Option Explicit
Public Sub Example()
    Dim Inspector As Outlook.Inspector
    Dim wdDoc As Word.Document
    Dim Selection As Word.Selection
        

    Set Inspector = Application.ActiveInspector()
    Set wdDoc = Inspector.WordEditor
    Set Selection = wdDoc.Application.Selection
        Selection.InsertBefore Format(Now, "DD/MM/YYYY")
    
    
    Set Inspector = Nothing
    Set wdDoc = Nothing
    Set Selection = Nothing
End Sub

enter image description here


Reference to Microsoft Word xx.x Object Library


Go to Outlook VBA editor either by pressing "Alt + F11" keys or clicking on the "Visual Basic" button in the “Developer” ribbon.

  • 1. In VBA editor window, click the "Tools" button in the menu bar.

  • 2. Then, from the drop down list, select the "References" option.

enter image description here

  • 3. In the dialog box, you can pull the scrolling bar down until you locate what you want, such as "Microsoft Word XX.X Object Library".

enter image description here