VBA runtime error 429: ActiveX component can't create object

G

Guest

I'm receiving the above error message when I instantiate Outlook in my VBA
code (I've pasted the code below). I'm using Access 2003 on Windows XP. The
code was working fine when I was running it on Window 2000 Professional
(still on Access 2003), but when I was upgraded to Windows XP recently, the
runtime error started occurring. Does anyone have any idea how I can fix
this.

Function SendEmail(ByRef olTo As String, ByRef olCc As String, ByRef olBcc
As String, ByRef olSubj As String, ByRef acqid As String, ByRef Internal As
Boolean)
On Error GoTo email_error
Dim msg As String
Dim path As String
Dim path2 As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
'***THE CODE FAIL ON THE NEXT LINE***
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

DoCmd.SetWarnings False

With MailOutLook
.BodyFormat = olFormatRichText
.To = olTo
.CC = olCc
.Bcc = olBcc
.Subject = olSubj
Call getBodyMsg(msg, path, Internal, acqid)

If acqid = "F" Then Exit Function

.Body = msg
.attachments.Add (path & acqid & ".xls")
path2 = Left(path, Len(path) - 19) & "Database Files\"
.attachments.Add (path2 & "Cover Sheet.xls")
.display
End With

DoCmd.SetWarnings True
Exit Function
email_error:
MsgBox "An error has occured. Please take a screen shot of this
error" & vbCrLf & _
"and forward it to the system administrator." & vbCrLf & vbCrLf
& _
"Error Number " & Err.Number & ": " & Err.Description,
vbCritical, "ERROR"
Resume Error_out
Error_out:


End Function
 
P

pietlinden

I'm receiving the above error message when I instantiate Outlook in my VBA
code (I've pasted the code below). I'm using Access 2003 on Windows XP. The
code was working fine when I was running it on Window 2000 Professional
(still on Access 2003), but when I was upgraded to Windows XP recently, the
runtime error started occurring. Does anyone have any idea how I can fix
this.

Function SendEmail(ByRef olTo As String, ByRef olCc As String, ByRef olBcc
As String, ByRef olSubj As String, ByRef acqid As String, ByRef Internal As
Boolean)
On Error GoTo email_error
Dim msg As String
Dim path As String
Dim path2 As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
'***THE CODE FAIL ON THE NEXT LINE***
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

DoCmd.SetWarnings False

With MailOutLook
.BodyFormat = olFormatRichText
.To = olTo
.CC = olCc
.Bcc = olBcc
.Subject = olSubj
Call getBodyMsg(msg, path, Internal, acqid)

If acqid = "F" Then Exit Function

.Body = msg
.attachments.Add (path & acqid & ".xls")
path2 = Left(path, Len(path) - 19) & "Database Files\"
.attachments.Add (path2 & "Cover Sheet.xls")
.display
End With

DoCmd.SetWarnings True
Exit Function
email_error:
MsgBox "An error has occured. Please take a screen shot of this
error" & vbCrLf & _
"and forward it to the system administrator." & vbCrLf & vbCrLf
& _
"Error Number " & Err.Number & ": " & Err.Description,
vbCritical, "ERROR"
Resume Error_out
Error_out:

End Function

you're mixing early and late binding. If you use CreateObject, you
need to declare your variables as OBJECT, not as OUTLOOK... I think
there is an example on Access web... www.mvps.org/access If not,
there are DOZENS here. Look for CreateObject
 
G

Guest

I tried your code but I'm still getting the error. Out of curiosity, I tried
running the code (the one I wrote) on a colleagues machine, who's also using
Access 2003 on Windows XP, and did not encounter the error. So, it seems to
be something related to my machine, not necessarily the code itself. Is
there a library or DLL file that I need to register on my machine? And if
so, which one?
 
R

Rick in NS

Manuel:

Did you every find out what registry entries are needed to get past this
problem? I have the same issue and cannot find a solution.
 
M

Manuel

Rick:

No, I was never able to find a solution to the problem. It's so strange
because the end user of the database I created is on the same OS (Windows XP)
and version of Access (2003), yet he doesn't get the error.

I'm not even sure that it's a registry problem.

I'll keep looking for an answer and if I find one I'll post it, but I've
been unsuccessful thus far. If you find a solution, please post it or email
me directly at: (e-mail address removed).

Thanks!
Manuel
 
R

Rick in NS

Manuel:

Thanks for the response. Will likewise notify you if I ever solve the
problem.
 

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