"Error in loading DLL" when looking for Outlook

KeithWilliams

Registered User.
Local time
Today, 21:40
Joined
Feb 9, 2004
Messages
137
Hi,

I am running the following code:
Dim objOutlook As Outlook.Application
Set objOutlook = GetObject(, "Outlook.Application")

I get the error number 48: "Error in loading DLL"

I am running MS Access 2000 SP-3. On this version I have the Microsoft Outlook 11.0 Object Library (MSOUTL.OLB ) available and I have added it in Tools > References. I have also tried copying the Microsoft Outlook 9.0 Object Library (MSOUTL.OLB ) to my machine and linking that in instead of the 11.0 library, but this makes no difference to the error.

I would be grateful for any help.

Thanks,
Keith.
 
Try...

Given that you have a reference to Outlook, you don't really need to "get" or "create" the object. This one line should work...
Code:
Dim ol As New Outlook.Application
 
Hi,

I attempt to get an existing Outlook instance to avoid the situation where every time the user starts the application, they get a new instance of Outlook. If the GetObject() fails, I call:
Shell("outlook", vbHide)
to create a new, hidden instance of Outlook.

What used to happen is the first time they run the application, they get a new, hidden instance, and on subsequent calls that hidden instance is re-used. The GetObject() used to work OK, and I am not aware of what may have changed in the environment to make it fail now.

Thanks,
Keith.
 
Using the New keyword to create the object creates a hidden instance, and as the programmer you can scope this instance so it's lifetime is consistent with your needs as determined by the task at hand.

You could, for instance, open a hidden form at application startup in Access, and expose...
Code:
Public olAppWide As New Outlook.Application
Then in any other form or module you can refer to it using
Code:
Form("YourHiddenForm").olAppWide
But I'd more commonly write that stuff into a class module which encapsulates specific procedures that my application would commonly perform using Outlook. I'd then instantiate my wrapper class when, and for as long as, needed.
 
Hi again,

OK, I tried declaring:

Public olAppWide As Outlook.Application

in a class module, then instantiating:

olAppWide = New Outlook.Application

but on the latter line, I get the same error 48.

At least its consistent! I hope you may have a suggestion. Thanks,
Keith.
 
Hi,

Sorry, that was my mistake. Corrected the syntax and I still get the same error!

Keith.
 
Keith:
Do you get the same results when a reference is set to Outlook 11 and when a reference is set to Outlook 9? (In Tools->References) Seems unlikely that Microsoft would allow you to simply copy in the .olb and use Outlook objects. Make sure the reference you are using is the same as the one you are able to run on your machine.
Mark
 
Hi,

Yes, I get the same error whether linking the library version 9 or version 11. Sorry, I gave the wrong name of the file for version 9, it is MSOUTL9.OLB, as compared with MSOUTL.OLB for version 11.

I am pretty sure version 11 is the one I should be running, but still getting the error.

Thanks,
Keith.
 

Users who are viewing this thread

Back
Top Bottom