Problem with Outlook Automation

N

Neil

I have some code I use to create a mail message in Outlook 2003 as follows:

Dim objOutlook As Outlook.Application
Set objOutlook = CreateObject("Outlook.Application")
etc....

The code works fine everywhere except on one computer. On that computer, the
user gets Error -2147024770: "Automation error. The specified module could
not be found."

I did some searching online, and I found that most of the time when people
got that message, it was because a DLL wasn't registered. So I looked up the
reference (in Access 2003) to "Microsoft Outlook 11.0 Object Library," and
it referred to msoutl.olb. However, that OLB file can't be registered,
because it's not an OCX or DLL.

So, any thoughts about what needs to be done here?

Thanks!

Neil
 
S

Sue Mosher [MVP-Outlook]

Try running Help | Detect and Repair in Outlook. It might also be worth knowing whether you can run any Outlook automation code in Outlook's own VBA environment.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Neil

Tried Detect and Repair. Didn't find anything.

I don't think there's anything wrong with the DLL; I just think it's not
registered. Unfortunately, I don't know which DLL it is. The file referenced
in Tools | References is msoutl.olb, which, if I understand correctly, is
just a library referencing other files? So I'm not sure which DLL or OCX is
causing the problem here, or else I'd just try Regsvr32 and try and get it
registered.

Neil


Try running Help | Detect and Repair in Outlook. It might also be worth
knowing whether you can run any Outlook automation code in Outlook's own VBA
environment.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Did you check out the other issue I suggested? Repeating:
It might also be worth
knowing whether you can run any Outlook automation code in Outlook's own VBA
environment.

If not, rerun Outlook setup to make sure its VBA component is installed.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

RobinS

I assume the user has Outlook installed? You could try reinstalling it
if possible and see if it's a problem with the installation.

Otherwise, you have to figure out which call is causing the problem,
and the only way to do that is to put a bunch of msgbox statements
in your code and run it on his computer. Maybe it's not the Outlook
calls causing your problem.

Robin S.
--------------------------------------------
 
N

Neil

Sorry, I thought I had posted it. I guess I forgot.

Yes, when run from within Outlook, the code works. Also, if I use GetObject
to access an open instance of Outlook from another app, it works on this
person's machine. But if Outlook isn't already open, then CreateObject
fails. Interesting.

Someone in the microsoft.public.access.interopoledde newsgroup replied that
this problem has been reported several times with no explanation or
resolution, and suggested GetObject as a workaround.

Neil

Did you check out the other issue I suggested? Repeating:
It might also be worth
knowing whether you can run any Outlook automation code in Outlook's own
VBA
environment.

If not, rerun Outlook setup to make sure its VBA component is installed.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

RobinS

Did you try
objOutlook = New Outlook.Application()
instead of using CreateObject?

I don't know which version of VB you're using. I used this for Excel
with VB2005.

Robin S.
---------------------------------------
 
S

Sue Mosher [MVP-Outlook]

The cause may be an anti-virus program on your computer that has a feature to block Outlook scripting. The solution is to turn off the script blocking feature. You may need to contact technical support for your anti-virus program to find out how to do that.


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Neil

No, that's not it. As stated, it works with GetObject and is able to create
the e-mail. Script blocking would block that as well.

But, it turns out, the fellow in the other forum stumbled upon a solution
that resolved it. Using CreateObject while specifying the host allowed the
command to go through. Don't ask me why (not that you would have anyway
;-) ). But when the following is used:

Set objOutlook = CreateObject("Outlook.Application", "LocalHost")

the problem is resolved. Again, this is only needed on one computer. On all
the others, the second parameter isn't needed. But on this one, CreateObject
only works with the host specified. Strange.

Neil


The cause may be an anti-virus program on your computer that has a feature
to block Outlook scripting. The solution is to turn off the script blocking
feature. You may need to contact technical support for your anti-virus
program to find out how to do that.


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Neil

Yes.

RobinS said:
Did you try
objOutlook = New Outlook.Application()
instead of using CreateObject?

I don't know which version of VB you're using. I used this for Excel with
VB2005.

Robin S.
 
S

Sue Mosher [MVP-Outlook]

That is strange. Good tip.

In my experience, GetObject() doesn't seem to be blocked by anti-virus programs, just CreateObject()

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Neil

That's interesting about GetObject working with anti-virus programs, but not
CreateObject.

In another twist here, the person on whose machine CreateObject didn't work
without "LocalHost" being specified uninstalled and reinstalled Office 2003,
and now it works fine with the original code (without "LocalHost").
Interesting.

Neil

That is strange. Good tip.

In my experience, GetObject() doesn't seem to be blocked by anti-virus
programs, just CreateObject()

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Mike

Are there any downsides to specifically using "LocalHost" as the
server name?

I am asking because I am thinking of adding this as a preemptive fix
to the automation error. Whenever I get a bug report for "Error
-2147024770: Automation error. The specified module could not be
found.", I always raise the possibility of script blocking anti virus
software, but this would be a great if it could eliminate most of
those support calls.

-mike
 
N

Neil

I don't see any, personally, as long as Outlook's installed locally. But
this isn't my code anyway. You might want to post your question in the forum
I referenced earlier in this thread, where the person who came up with this
posted it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top