Outlook automation help requested

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • salad

    #1

    Outlook automation help requested

    I'm on A97 and have Outlook 2003 on the computer. There's some generic
    code at Tony Toew's site and at MS and on the web that's very
    similar....but I can't make it work. I want to use late binding but it
    appears I'm not having much luck. The code works ONLY if Outlook is loaded.

    I'm a bit unfamiliar with Outlook...been using Netscape for way too
    long. When I start Outlook, it prompts me for a profile. How do you
    handle that via Automation? Next, if Outlook is not loaded, the
    CreateObject bombs out.

    I suppose I could check for Outlook's class name and if Outlook isn't
    loaded then simply tell the user to start Outlook first. But that's
    kind of kludgy. I'm hoping there's a better way...and that you have the
    solution. TIA! Below is the code I am hoping to get to work.

    Dim olMailItem As Integer
    Dim olTo As Integer
    Dim olcc As Integer
    Dim olbcc As Integer
    Dim olImportanceHig h As Integer

    olTo = 1
    olcc = 2
    olbcc = 3
    olImportanceHig h = 2
    olMailItem = 0

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

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

    '******here is where it bombs out****
    Set objOutlook = CreateObject("O utlook.Applicat ion")

    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
Working...