MSAccess "MISSING: Microsoft Outlook 15.0 Object Library"

darls15
darls15 used Ask the Experts™
on
Hi Experts

I have an Access 2010 database which generates a simple email messages with code I came across. Everything was working perfectly until another user opened the database in Access 2013.

I'm now getting errors and in the code window under TOOLS>>REFERENCES I'm getting a "MISSING: Microsoft Outlook 15.0 Object Library" error message.

I'm presuming this is related to the different Outlook versions but due to my lack of knowledge in this area, I really don't know how to fix it or even know if it can be.

Can anyone please advise? I have pasted the code below...

Thanks in advance
darls15


'**************************************************************

Option Compare Database

Public Sub cmdSendAcademyID_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

'*create string with email address

strEmail = Form__F_SendLogonDetails![EmailAdd]

strBody = strBody & "<FONT Face=Arial Color=#000000 Size=3>"
strBody = strBody & "Dear " & Form__F_SendLogonDetails![txtFName]
strBody = strBody & "<br><br>"
strBody = strBody & "The unique " & " <b> " & "ID" & "</b>" & " for the IT Academy at " & " <b> " & Form__F_SendLogonDetails![Centre Name] & "</b>" & " is " & " <b> " & Form__F_SendLogonDetails![MemberID] & "</b>" & ". Please be aware that you will also need the " & " <b> " & "Program Key" & "</b>" & " associated with your subscription to add a new Administrator. This will be sent to your school in a separate email."
strBody = strBody & "<br><br>"
strBody = strBody & "Should you require further assistance please phone 1234 5678 or email the team at ITAcademy@somewhere.com"
strBody = strBody & "<br><br>"
strBody = strBody & "Regards"
strBody = strBody & "<br><br><br><br>"
strBody = strBody & "Project Team"

'***creates and sends email
With objEmail
   
'Set body format to HTML
    .BodyFormat = olFormatHTML
   
    .SentOnBehalfOfName = "ITAcademy@somewhere.com"
    .To = strEmail
    .BCC = "joe@somewhere.com"
    .Subject = "Academy ID for " & Form__F_SendLogonDetails![Centre Name]
    .HTMLBody = strBody
    .Send
End With

Set objEmail = Nothing
Exit Sub
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013
Commented:
Open your database with MS Access. Press <Alt>+<F11> keys. This will bring up VBA editor. From the menu select Tools->References. There will be a reference marked as missing, like this:
MISSING: Microsoft Outlook 15.0 Object Library

Open in new window

Unselect this missing reference. Select another Microsoft Outlook xx.xx Object Library from the list. Close the reference dialog (Press OK). Save your database and try again
President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
Yes, that's it exactly.  The code your using relies on Outlook being installed.   It also was relying  on a specific version of Outlook.

  The Office references usually auto fix themselves, so my guess is this user has Access installed and not Outlook.  They'll need to install it if you want this code to work.

  There are different methods of sending e-mail that do not rely on Outlook if that's all your doing (sending e-mail).

  Also you can avoid reference problems by declaring objects as generic objects rather than Outlook specifically.  So instead of:

Dim objOutlook As Outlook.Application

you do:

Dim objOutlook As Object

  The object type is not looked up until runtime, so you don't need a specific reference set.  You do loose intellisense though.  

  Many developers develop using early binding (like you have), then switch to late binding for distribution).

Jim.
Most Valuable Expert 2012
Top Expert 2014

Commented:
One more thing - you obviously have users who are sharing the SAME database, which is why that user's reference change affected everyone else. The suggested way to share an Access database is to "split" the database into a BackEnd (the Tables only) and a FrontEnd (everything else), then "link" the tables from the BE in the FE. Then, you make copies of the FE and distribute those to each user who needs to use the database.

Still, you should consider using Late Binding, as JimD suggests. If you do this, remember that you have to declare your Constants as well. the constant "olMailItem" will no longer be available if you remove the reference to the Outlook library, so you'll have to declare that in code:

Dim olMailItem As Integer
olMailItem = 0

Author

Commented:
Thank you both, this is much clearer now. I ended up declaring the objects as generic objects and everything is working as it should. I appreciate your responses.
if I install access run time .. Can i overcome this issue?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial