creating a macro for inserting text

  • Thread starter Thread starter david
  • Start date Start date
D

david

i'd like to have a macro that i can run which will insert
a specified list of words. can anyone tell me the code to
insert text into an outlook message.

thanks
 
Try this macro:

Sub InsertWordsIntoEmailBody()
Dim objInsp As Outlook.Inspector, objItem As Object
Dim strWordArray(5) As String

Set objInsp = Outlook.ActiveInspector

If objInsp Is Nothing Then
'No open e-mail message
Exit Sub
End If

Set objItem = objInsp.CurrentItem

strWordArray(0) = "My"
strWordArray(1) = "string"
strWordArray(2) = "array"
strWordArray(3) = "list"
strWordArray(4) = "of"
strWordArray(5) = "words"

objItem.Body = Join(strWordArray, ";") & vbNewLine & vbNewLine &
objItem.Body
End Sub
 
many thanks that works.
can you tell me how I can insert this list at the point
in the email where the cursor currently is?
 
Unfortunately, you can't do that with the Outlook Object Model. You need to
use the SafeInspector object from the third-party Redemption tool
(http://www.dimastr.com).

Eric Legault - B.A, MCP, MCSD, Outlook MVP
 
If you set Word as the email editor, you can use the Word AutoText feature
without any programming, to insert text at the cursor.
 
Back
Top