Library Not Registered Error

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,030
OK this has had me doin' the :banghead: now for three hours. I am just plain out of ideas...

Got new notebook. (Don't get me started...)

Trying to run code that worked perfectly well on old machine, but blowing apart on new machine...

The crux of the matter:
Code:
Sub emailReports()
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    Const cstrMsgFileName As String = "e-mail text.html"
 
    '// __booleans___________
    Dim booIStartedOutlook As Boolean, _
        booIOpenedDataWB As Boolean, _
        booScrnUpdate As Boolean
 
    '// __integers___________
    Dim hndInput As Integer, i%, p&
 
    '// __objects: outlook___
       Dim appOL As Outlook.Application, _
        emlNew As Outlook.MailItem, _
        objRecipients As Outlook.Recipient
...
    '// Create a Handle to Outlook
    On Error Resume Next
    Set appOL = Nothing
 
    Set appOL = GetObject(, "Outlook.Application")
    MsgBox "app is " & IIf((appOL Is Nothing), "", "NOT ") & "nothing.", vbInformation
    On Error GoTo CleanUp
    If appOL Is Nothing Then
        booIStartedOutlook = True
        Set appOL = New Outlook.Application
    Else
        booIStartedOutlook = False
    End If
...
This code worked just fine on the old 'puter. Now she throws a shoe every time. If I change the On Error Resume Next to On Error GoTo 0 before calling GETOBJECT, I get a "Error -2147319779... Library not registered"



I have tried everything I can think of to get this to work and nothing is helping. I have
Nothing works to resolve this error.

The only workaround was to change all the DIM statements to declare as generic OBJECTS. Then the code works just fine. But how the devil does one actually fix this? :confused: Like I said, the same code runs just fine on my old machine. :mad:
 
Last edited:
Same here. I had Office 2010 installed and SharePoint Designer 2013. Apparently, if you install any office component that belongs to a suite that is newer than the version that Excel runs in then it causes problems like this VBA error. Other symptoms in my case were that the option in Excel to "Send the current sheet as the message body" of an email was failing to launch outlook and the open this whatever in Outlook functionality of our SharePoint site stopped working as well. The underlying issue appears to be that any program that relies on the Microsoft Outlook libraries fails because the newest installed component installs and registers Outlook 2013 DLLs on the system and VBA always uses the DLL with the newest version. If you are using the 2013 DLL, but you don't have Outlook 2013 installed on your PC then things go horribly from there on.

An easy way to spot this issue conclusively is to go into the Tools menu of the VBA editor in Excel and go to the References option. If you have this issue then you will see that the Microsoft Excel Object Library will have an older version than the Microsoft Outlook Object Library (in my case with Excel 2010 and SPD 2013 it displays as Excel 14.0 and Outlook 15.0).
To fix it you have to remove the reference to the newer library in your registry -or- uninstall that program which removes it as well. In my case I just uninstalled SharePoint Designer 2013 and installed the 2010 version instead. When I launched Outlook after that the first run wizard popped up and automatically re-registered all the 2010 DLLs. After that everything started working normally and Microsoft Outlook 14.0 Object Library showed up in references. The newer registry key that didn't belong automatically vanished from the registry so I didn't wind up having to mess with that.

One thing to be careful of with the registry hack. The key didn't just magically show up, some office installer put it there. In my case it was SharePoint Designer 2013 and, as it happens, our SP server is 2010 anyway so I could uninstall that. If I did have use for SPD 2013 and decided to use the hack mentioned, I would imagine that it may have wound up causing errors in SPD 2013 if I tried to reference the Outlook library in that program. I have no way to test, but if you remove the newer registry key be sure to back it up in case it breaks the newer Office component that installed it.

P.S. In Greg's fix he deleted [HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.3] which mentioned in a sub-key that it was tied to Outlook 12.0.0.0 (aka 2007) and he was using 11.0.0.0 (aka 2003). This issue seems to still exist on much newer versions as well. A more universal approach would be this:
*You'll need admin rights to do any of this.*
1. Open RegEdit and navigate to HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}
2. Within that key you will see a sub-key for each version of the Outlook DLL you have registered
a. The sub-keys should have names like 9.1, 9.2, 9.3, 9.4, 9.5, etc
b. If you only find one sub-key in here then this is not your problem and this fix is not for you
3. If you click the key you will see a property called PrimaryInteropAssemblyName and the data value will indicate the outlook version
4. Find the key with version of Outlook you are running (2010 was version 14 which was a key named 9.4 in my case)
5. Export any keys with a version greater than that (in my case SPD 2013 had created key 9.5) and keep them in a safe place
6. Delete those keys and then re-launch Outlook and any other Office programs you have running
7. If something else breaks then double click the exported key file you saved to put it back.
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I'm glad to hear that this helped you! (Well, sorta glad -- it would have been better had you never wasted those eight hours! :wink:)

Also, I should note that on the other forum where I posted this problem, a fellow in Germany wrote

So depending on one's circumstances, perhaps this tidbit might help.

Wow, this post is the gift that keeps on giving. I'd deleted all references to other (not installed) outlook versions...but thanks to this post, found the folder (9.6 in my case) that was the problem and deleted it. Bingo.

Not sure how it ever happened in the first place, but my problem is fixed. Thanks a million - been looking for help for days, and Microsoft had no idea either. (Not super surprising).

Thanks!
Mike
 
Upvote 0

Forum statistics

Threads
1,223,770
Messages
6,174,437
Members
452,564
Latest member
crangelag

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top