Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Error: Object library feature not supported Outlook.Application

I have been tasked with fixing an issue in VB on an Microsoft Access system and I can't figure it out. This issue only occurs on one of the 5 PC's running the software. I have tried

  • Removing Outlook & Access and re-installing it.
  • Removing the Microsoft Access Application and re-installing it.
  • Changed the code to match an answer I have found on another site.

This code brings up an error enter image description here The code is as follows.

    Dim objOutlook As Outlook.Application
    Dim objMailItem As MailItem
    Dim db As DAO.Database

    'Create email object and send attachment

    Set objOutlook = DetectOutlook()
    If objOutlook Is Nothing Then
        Set objOutlook = New Outlook.Application
    End If

I tried changing it to this as recommended on another site.

    Dim objOutlook As Object
    Dim objMailItem As MailItem
    Dim db As DAO.Database

    'Create email object and send attachment

   If GetObject(, "Outlook.Application") = True Then    'Outlook was already running
        Set objOutlook = GetObject(, "Outlook.Application")    'Bind to existing instance of Outlook
    Else    'Could not get instance of Outlook, so create a new one
        Set objOutlook = New Outlook.Application
    End If

This code change just ended up forcing Access to shutdown when it was run. I am new to VB and Access Development so maybe this is a simple fix, if you require any further information please ask. Its 2016 Microsoft FYI. Thank you in advance

like image 954
rbaskam Avatar asked Jun 23 '17 09:06

rbaskam


2 Answers

You might as well try a weird workaround suggested by Dreadfool at MSDN. It doesn't require you to change a line of code.

Just save the macro into another file and import this new file to your project. This simple step helped in my case, when code stopped working after an update of 365.

like image 64
BusinessAlchemist Avatar answered Oct 21 '22 05:10

BusinessAlchemist


I suspect the issue is incorrect references to different outlook versions.

You need to employ late binding if there is a possibility of different versions of outlook or access being used with your user environment. The second code you posted is halfway there but I would suggest having a read up here; http://sourcedaddy.com/ms-access/late-binding.html

like image 24
Minty Avatar answered Oct 21 '22 03:10

Minty