Outlook automation with Access

  • Thread starter Thread starter salad
  • Start date Start date
S

salad

I'm on A97 and have Outlook 2003 on the computer. I want to use late
binding (not set references) but it appears I'm not having much luck.
The code below works ONLY if Outlook is loaded.

When I start Outlook, it prompts me for a profile. How do you handle
that via Automation? (I don't have any code for that)

Next, if Outlook is not loaded, the CreateObject (in the code below)
bombs out.

If you have any idea on how to start Outlook and handle the profile or
know why I can't get CreateObject to work I'd like to shake your hand
for the help. Here's my code. TIA.

Dim olMailItem As Integer
olMailItem = 0

'Create the Outlook session.
Set objOutlook = GetObject(, "Outlook.Application") 'get reference

'if Outlook is already running.
If Err.Number = 429 Then 'Error 429occurs if Outlook is NOT running.
Err.Clear

'******here is where it bombs out****
Set objOutlook = CreateObject("Outlook.Application")

MsgBox Err.Number
If Err.Number = 429 Then
MsgBox "MS Outlook is not installed on your computer"
Exit Sub
End If
End If
...rest of code processes
 
If the user has Outlook set to prompt for a profile when Outlook starts, I don't think you can avoid getting a prompt from CreateObject.

What exactly are you hoping to accomplish with your Outlook automation? There may be alternative approaches.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue said:
If the user has Outlook set to prompt for a profile when Outlook
starts, I don't think you can avoid getting a prompt from
CreateObject.

What exactly are you hoping to accomplish with your Outlook
automation? There may be alternative approaches.

Hi Sue:

I basically want to send an email from Access. I can get the class name
to determine whether or not Outlook is loaded (this is the method I
currently use for Groupwise). Thus I could tell the user "Hey, Outlook
isn't loaded. You need to open it before we can send an email". I was
thinking there may be another alternative of opening Outlook from a dead
start.

But what you say makes sense. The code is for sending emails, not
opening outlook if it isn't loaded, determining the profile, then
sending an email. There'd be too much opportunity for errors.
FYI, there is a newsgroup specifically for general Outlook
programming issues "down the hall" at
microsoft.public.outlook.program_vba or, via web interface, at
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

I think I would go there except for one thing...I'm responding to a
person that's an authority and mentor in all facets of Outlook. I'll do
a quick google check but I'm confident you gave me all I needed to know.
 

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

Back
Top