Outlook Macros Part 2

January 6, 2010

In Outlook Macros Part 1 I managed to use a macro that generated an email with a specified subject and body. Now it’s time to look at forms.

I forgot to say last time how to get to the visual basic editor. In Outlook 2003 you go to tools->macro->visual-basic-editor. When I do this, Outlook asks me if I want to enable or disable macros. I enable. I’m not sure how to put this as default yet.

Then I hit insert->module and entered this code:

Public Sub helloDorks()
Dim msg As Outlook.MailItem
Set msg = Application.CreateItem(olMailItem)
msg.Subject = “Space Station”
msg.Body = “What’s the progress on warp drive? When will it be online? My gerbils are getting tired and I’m running out of carrots.”
msg.Display
Set msg = Nothing
End Sub

I then saved and hit run, and yay! I got a new mail message.

Now I want a prompt that asks me to choose an email template, and the information to fill out that template (email, phone number, company name, etc.) For that I’m pretty sure I need forms, which are basically popup windows. I hit insert->user-form and I’ve got one. I can resize it, add text boxes, radio buttons, everything I need. Now I just need to know how to make my fancy box actually work

It looks like I can write code for a button just by double clicking it. I’ve whipped up a quick sketch of the form I want and am almost finished making it. Currently I’m trying to figure out how add items to a listbox.

to be continued….

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.