CreateObject("Outlook.Application") Error

S

Shannon

I am using the code below to send an email from Access. It works fine on
some machines but on others I get this error message:

Run-time error: '-2147319779 (800280id)':

Automation error
Library not Regristered


The offending code is

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application") - this is where the
error occurs
Set objEmail = objOutlook.CreateItem(olMailItem)

All machines have the same references ticked and none are missing.

Any help would be much appreciated.

Thanks

Shannon
 
T

Tony Toews [MVP]

Shannon said:
All machines have the same references ticked and none are missing.

Do those machines have the same version of Outlook that you do and
that the machines which work have?

Although I would expect the reference to be missing in that case.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
S

Shannon

Hi Tony,

All machines are running Access 2003 and Outlook 2003. All installed in the
same location.

Some are running Vista and some XP SP2, although some of both work and some
don't.

Shannon
 
B

boblarson

Instead of

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Use

Dim objOutlook As Object
Dim objEmail As Object

because you are currently mixing early binding and late binding. So, since
you are using the CreateObject method (late binding) use it all of the way.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
S

Shannon

Thanks Bob,

Works perfectly now.

Shannon

boblarson said:
Instead of

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Use

Dim objOutlook As Object
Dim objEmail As Object

because you are currently mixing early binding and late binding. So, since
you are using the CreateObject method (late binding) use it all of the way.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
A

Arvin Meyer [MVP]

CreateObject merely instantiates a new instance. GetObject uses a curently
open instance. Both are used by early and late binding. You are correct in
the difference of the way they are dim'd.
 
B

boblarson

I guess that is so (http://support.microsoft.com/kb/245115) but myself, I've
seemed to have trouble when using CreateObject when I've selected
Excel.Application as an early binding object. I will typically use Set
appExcel = New Excel.Application instead of using CreateObject when using Dim
appExcel As Excel.Application. I've not had issues when doing it that way,
but I have had issues at times when using CreateObject when I've declared it
as early binding, even though the article says it should be okay. Every time
I've suggested someone change it when they've used it that way, their problem
goes away, so I had concluded that it was not good to mix them. But,
whatever works then do it that way.

As for me, I will stick to my current method as I've not had any problems
with it.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
A

Arvin Meyer [MVP]

Quite a few developers use Early Binding at the start of coding because it
allows the use of Intellisense. I normally leave it that way because Early
Binding is slightly faster. However, there are places where Late Binding is
preferable, such as shrink-wrapped software and MDEs. By using Early Binding
to start, coding is faster, then one simply needs to change the Dim'ing
from:

Dim objOutlook As Outlook.Application
to
Dim objOutlook As Object

and delete the reference. The rest of the code is essentially the same. It's
just a matter of style in the way the work is done. As far as issues, I've
never had a problem either way.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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