Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2000 VBA macro

Status
Not open for further replies.

Peahippo

MIS
Jul 18, 2003
91
US
I used to generate Excel macros by a recording feature, and then edit the resulting VBA code. But Outlook 2000 stymies me. There's no "record a macro" feature.

I wanted a macro that when run, produces a new mail item, with no signature or subject, and with the recipient address already entered in the To line ... so I could then type in a short message and just click send. This seemed the quickest way to email-page my coworker.

The macro I made from samples on the net looks like this:

Sub PageCoworker()
' MsgBox FormatDateTime(Now, vbLongDate)
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = "1235551234@somepagingservice.com"
olMail.Subject = ""
olMail.Body = "TEST"
End Sub


... but when run, produces a couple of seconds of hourglass and then nothing. The test line runs when I enable it, so the macro is actually running.

What's wrong with this code? My Outlook macro security setting is LOW (I'm on an intranet).
 
Try adding olMail.Display after the olMial.Body line.
 
That fixed it! Thank you.

If I can take up a bit more of your time ... I then tried "olMail.Body.Focus" to get the cursor in the body (so that I could immediately start typing after running the macro), but that didn't work. Any idea?
 
I'm not too hot on Outlook, have you tried olMail.Body.Activate?
 
Nope, "olMail.Body.Activate" gives me an "invalid qualifier" error. I'll surf a bit to finish off the macro; again, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top