creating a macro for inserting text

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
 
E

Eric Legault [MVP - Outlook]

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
 
D

david

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?
 
E

Eric Legault [MVP - Outlook]

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
 
S

Sriram

If you set Word as the email editor, you can use the Word AutoText feature
without any programming, to insert text at the cursor.
 
Top