Macro to add text to a Message

E

Emma Aumack

Hi all,

Although I have used VBA in Excel, I have never used it in Outlook. Using
Outlook 2007, What I would like to do seems simple enough but I have no clue
how to do it. All I want to do is add text to the body of a message. I
thought something like this would work but I get the error message "Sub of
Function not defined". I know I'm missing an event or something but I'm not
sure. Can someone please help?

Sub APPRVL_REQ_TEXT()

Dim Aprvl_Text As String

Aprvl_Text = "Your approval is requested for the following contract
renewals. Please also see sales data below:"

End Sub
 
E

Emma Aumack

Ok. I've gotten this far but this code opens a new message. I want to
insert text into an existing open message and I am still getting the "sub or
function not defined error" when I try to run the macro. But I don't get it
when I "step into" the macro.

Sub APPRVL_REQ_TEXT()

Dim msg As Outlook.MailItem
Dim ApprovalText As String

ApprovalText = "Your approval is requested for the following contract
renewals. Please also see sales data below:"
Set msg = Application.CreateItem(olMailItem)
msg.Body = ApprovalText
msg.Display
Set msg = Nothing
End Sub


Any help would be greatly appreciated.

Emma
 
S

Sue Mosher [MVP]

How are you trying to run the macro when you get the error?

To return the currently open item in Outlook VBA, use
Application.ActiveInspector.CurrentItem.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
E

Emma Aumack

Just from the macros icon in the developer menu.

Also, I tried to get into the macro today and now I get an error message
that says "The macros in this project are disabled. Please refer to the
onlin ehelp or documentation of the host application to determine how to
enable macros." So I looked online and the help says to open the document
with Enable Macros but NOWHERE do I see how to enable macros in a project.
 

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