Macro creation for Outlook insert subject

D

damadhatter

I have a user who wants to create a simple Outlook Macro to insert the
same line of text into the subject field in Outlook that they have to
type 100's of times a day. They are using Windows XP SP3, Outlook 2007
w/SP2, anybody who could help?

I have found this online (see below), which works, but you have to have
an email open. I would like to have one that opens a new email with the
subject line inserted.

Sub InsertSubject()
Dim olkMsg As Outlook.MailItem
'Get the currently open message'
Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem
olkMsg.Subject = "My text"
'Destroy the object to avoid memory leaks'
Set olkMsg = Nothing
End Sub

I also found this which users say should work for exactly what I need
it for, but when putting it in VB editor the line with
"Outlook.Application" is highlighted in red and when trying to run it I
get a compile error.

Public Sub NewEmail()
Dim objApp As Outlook.Application
Dim objMessage As MailItemSet objApp =
CreateObject("Outlook.Application")
Set objMessage = objApp.CreateItem(olMailItem)
objMessage.Subject = "My Text"
objMessage.Display
Set objMessage = Nothing
Set objApp = Nothing
End Sub


I am a server admin, so I don't know much about this stuff, just trying
to help a user/friend out. Any ideas would be great! Thanks guys!
 
S

Sue Mosher [MVP]

Set olkMsg = Application.CreateItem(olMailItem)
olkMsg.Subject = "My text"
olkMsg.Display
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top