I cannot get MS Outlook 2010 to launch from MS Access 2003 VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rugbykorn
    New Member
    • Mar 2012
    • 15

    I cannot get MS Outlook 2010 to launch from MS Access 2003 VBA

    Hi,

    I am trying to get MS Outlook 2010 to launch when I execute some VBA in MS Access 2003. I am trying to keep this simple since I am just getting started on this project and like to go step by step. I expected this to go relatively smoothly but Outlook 2010 doesn't seem to launch properly.

    When I execute the following:

    Code:
    Private Sub Test_Click()
    
    Dim Olook As Outlook.Application
    
    Set oLook = CreateObject("Outlook.Application")
    
    End Sub
    The outlook icon appears on the bottom right in the system tray but outlook doesn't launch. The outlook process (as seen in task manager) launches but then closses shortly there after.

    I have tried different variations of 'olLook.Applica tion.Visible = True' to see if that was the issue and that returns an error. I tried using some code from various websites that would create a new email but those didn't work as well. I'm thinking that something changed in Outlook 2010 and the code I can find online is only applicable to earlier versions.

    Any suggestions would be much appreciated as the advice I have gotten on this forum before was most helpful.


    I have also tried:

    Code:
    Private Sub Test_Click()
    
    Dim Olook As Object
    
    Set oLook = CreateObject("Outlook.Application")
    
    End Sub

    Thanks,

    Rugbykorn
    Last edited by Rabbit; Oct 11 '12, 10:07 PM. Reason: Please use code tags when posting code.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Try this walk thru:

    The change here is going to be the
    5.In the References box, click to select the Microsoft Outlook 11.0 Object Library, and then click OK.
    as I think you will need the Outlook 14.0 Object Library in order for you to work with V2010. I have some code that works along these lines as I use it to have application errors interactively emailed to be during the Alpha and Beta testing of my applications.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      You could try going through Application Automation. It has an Outlook example included. It accessses the Outlook.Applica tion object differently from your code.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Thank you Neopa,
        I was trying to find that link in the insights and had started to believe that I had read it somewhere else.

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          I believe that Outlook 2010 functions a bit differently when used through automation. For example it will only show up as an icon in the bottom right corner. If you mouseover the icon it will say something about being used for automation, or that it is being used by another process.

          The reason it closes again, is that as your procedure ends, the variable falls out of scope and is closed and cleared. If you were to dimension your variable outside your procedure, as a module level variable it would stay open (But still only show in the bottom right corner). If you create an email for example and choose display, then the outlook email window would show up and be visible.

          I am no expert on the automation of outlook, the above is based on a bit of experience, and how I remember it.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            That certainly makes sense Smiley. I didn't spot that the code killed the object as soon as it was created. Not the best way to close down the app, but would probably have that effect as there would no longer be a handle available to point to it. I'm not certain it always did it that way though. I might be wrong but I believe in older versions you could persist the object once created as long as it was never closed explicitly. Easy enough to test for too. Good call.

            Comment

            Working...