I wish to create a macro that inserts the date into an email body which is currently open for editing, prior to sending.
I am using Outlook 2013 on
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
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.
- 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".