Modifying an Excel 2000 Macro

G

Guest

Using Excel 2000, I have this macro, listed below, which creates a new blank
e-mail message. I would like to modify it so that when the macro executes
and the new e-mail is created an e-mail address automatically is entered in
the To: field.


Sub Send_Form()
'
' Send_Form Macro
' Macro recorded 20/03/2006 by LPS. Used to send form as an E-Mail attachment
'

'
Application.Dialogs(xlDialogSendMail).Show

End Sub


Thank you for any and all help.
 
G

Guest

If you set a reference to the Outlook Object model, you can populate all the
fields in your mail message:

Sub test()

Dim ol As Outlook.Application
Set ol = New Outlook.Application

Set oMessage = ol.CreateItem(olMailItem)
oMessage.Display
oMessage.To = "(e-mail address removed)"

End Sub
 
G

Guest

Thank you for your suggestion. I copied and pasted the code into my macro
and tried it and got the following error:

Compile Error:

User-defined type not defined.

I know very little about macros so if I needed to edit your code, I would
not know what edits to make. Suggestions???

Again, thanks for your help
 
S

Sandy

Look in the help section of the VBE and look for Built-In Dialog Box
Argument Lists under xlDialogSendMail you will see some arguments to
the right you can use for Subject, Recipient, and return receipt.
Heres an example:

Application.Dialogs(xlDialogSendMail).Show arg1:="Recipients Name",
arg2:="My Subject"

Good luck,

Sandy
 

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