Outlook - Issue with missing reference

RichO

Registered Yoozer
Local time
Yesterday, 21:21
Joined
Jan 14, 2004
Messages
1,036
The database I work on has 3 users. Only one of the users has Outlook installed and uses it through Access for emailing information to customers. The other 2 users do not do this and do not have Outlook installed.

The problem I always face is that anytime I copy an updated MDB to the other 2 users there is an error because the Outlook reference is missing and I have to alter some of the VBA to get rid of the Outlook related items.

Is there any better way to handle this, besides installing Outlook on the other 2 computers? Would be nice to have a way to tell Access to ignore Outlook related code. I do have an "If....Then" statement that goes around the Outlook usage if it's not the one specific user that uses Outlook but just the fact that the code exists in the module causes an error even if it doesn't execute.
 
You can switch the code to late binding, which doesn't require the reference.
 
Didn't even realize that was an option. So when I have this:

Code:
    Dim olApp       As Outlook.Application
    Dim olnamespace As Outlook.NameSpace
    Dim olMail      As Outlook.MailItem
    Set olApp = New Outlook.Application
    Set olnamespace = olApp.GetNamespace("MAPI")
    Set olMail = olApp.CreateItem(olMailItem)

Is it as simple as changing it to

Code:
    Dim olApp       As Object
    Dim olnamespace As Object
    Dim olMail      As Object
    Set olApp = CreateObject("Outlook.Application")
    Set olnamespace = CreateObject(olApp.GetNamespace("MAPI"))
    Set olMail = CreateObject(olApp.CreateItem(olMailItem))

Or am I missing something here? Thanks!
 
Constants like olMailItem typically don't work with late binding. You have to switch them to their numerical equivalents. If memory serves, that one is 0.
 
OK, I will look into that.

However, this isn't going to fix the issue with the missing reference is it? The missing reference causes Access to give false errors.
 
Again, with late binding you don't need the reference. Uncheck it.
 
Oops, sorry I didn't recall that being mentioned in your original answer.
 
No problem. Got it working okay?
 
I've looked up a few code samples online but haven't gotten around to working on it yet :)
 

Users who are viewing this thread

Back
Top Bottom