Compile Error: Object library feature not supported Outlook.Application
Asked Answered
C

6

9

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

Countershading answered 23/6, 2017 at 9:32 Comment(2)
I suspect the issue is reference 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; sourcedaddy.com/ms-access/late-binding.htmlDiantha
That was it thank you. Using my second answer I changed Set objOutlook = New Outlook.Application to Set objOutlook = CreateObject("Outlook.Application") If you want to add that as an answer I will accept it. Thank you very muchCountershading
D
5

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

Diantha answered 23/6, 2017 at 11:41 Comment(0)
H
12

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.

Hagler answered 2/8, 2017 at 6:39 Comment(6)
Thank you for the answer. If this occurs in the future I will look into this method.Countershading
This worked perfectly for me. I started having issues after Office Update. I rely heavily on VBA code for automated report generation. My code was in Module1 in Outlook VBA. I right-clicked Module1 and then exported the code in a file. Then I right-click again and remove module, click No when prompted to export (already exported). Then again right-click and click Import and select the file exported earlier. The code started working again.Meritocracy
goodness. this error has disturbed me for years coz i primarily use vba for like since ever. so it was always export import code???Campball
What worked for me was opening the VB editor and then going into Tools > References. I had to check a few more references (OLE Automation, EBApp, etc). I ran the Macro again an no errors came up.Succoth
Worked for me! Didn't even have to restart Outlook. Just export, delete and import.Starlin
Thanks for this, I suddenly had issues with the Excel object in Access, tried removing and re-adding the reference with no improvement, but exporting all the Class modules which use the Excel object, then reimporting them has done the trick. This also after an update of Office 365. With no disrespect to the accepted answer, this is far superior to late-binding in my use-caseAmorphism
D
5

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

Diantha answered 23/6, 2017 at 11:41 Comment(0)
G
3

Oddly enough and I'm not sure why, I resolved this following a slightly different version of this user's advice:

What worked for me was opening the VB editor and then going into Tools > References. I had to check a few more references (OLE Automation, EBApp, etc). I ran the Macro again an no errors came up. – jpruizs May 9 '18 at 2:52

Instead, I had all the relevant object library references, but I reprioritized them as follows:

  1. Visual Basic for Applications
  2. Microsoft Outlook 16.0 Object Library
  3. Microsoft Office 16.0 Object Library
  4. OLE Automation

Somehow this worked and I no longer received the compile error. I was pretty sure library reference was the culprit, because I had copied the macro text from another system where it worked fine.

Godfrey answered 16/12, 2021 at 20:33 Comment(1)
My code was working fine until, one day, it wasn't and produced this error. I took this approach and moved OLE Automation to the end of my reference list and that solved the issue.Rave
C
1

After very recent MS Office update this "Object library feature not supported for Outlook.Application" error started happening in our tools.

Putting 'Microsoft Outlook 16.0 Object Library' as high priority as possible solved the issue.

Climacteric answered 19/7, 2022 at 9:50 Comment(0)
I
0

Just had the same problem, Outlook macros stopped working (same error message, but on a "GetFolder" call) after installing Visio 2016 64bit side by side with an Office 2016 ProPlus 64bit installation.

First tried a reboot -> no effect.

Then tried an offline repair of Office -> no effect.

Then an online repair -> made it work again.

Instar answered 20/10, 2017 at 13:29 Comment(0)
V
0

When you upgrade office to 2019 or office 365 version, you require to re-import your custom development i.e. all the modules, forms etc in vba.

Just export all the modules in one folder, remove it and import it again. It will solve the problem.

Vigor answered 20/6, 2019 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.