ActiveX component

G

Guest

I have searched through this newsgroup/form thing for information on this and
tried a few things in the KB article, however I'm still getting a problem.

I have a button on frmFirst with the code to send an email from Outlook with
a subject line that includes a field from frmFirst. I originally created
this form and coding when I had Outlook 2000 and referenced the library,
Microsoft Outlook 9.0. I recently upgraded to Outlook 2003 and referenced the
library Microsoft Outlook 11.0.

Both Outlooks are used by staff members (some have 2000, some have 2003 -
everyone has Access 2000). Now, on my computer I can click the button and
open an email quite fine. On a computer with Outlook 2000, it was working but
since the Object Library 9.0 has disappeared it's not working. But whatever I
do, I cannot get it to open an email on another computer with Outlook 2003
(get message: ActiveX component can't create object).

I have tried re registering the DAO library.

I have the following libraries referenced in the Visual Basic application:
Visual Basic for Applications
Microsoft Access 9.0 Object Library
Microsoft Outlook 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Office 11.0 Object Library
 
D

Douglas J Steele

Whenever you've got a mixed environment like that, where different users can
have different versions of the same product, you're best off using Late
Binding, so that you don't need to set a reference at all.

Rather than having something like:

Dim objOutlook As Outlook.Application

Set objOutlook = New Outlook.Application

you'd use

Dim objOutlook As Object

Set objOutlook = CreateObject("Outlook.Application")

The "trick" is that you need to ensure you're not using any named constants
defined in the Outlook library: you either need to define those constants in
your Access code, or replace the named constants with their actual value.
 
G

Guest

What you've suggested is very similar to the code I already have. I read
about early/late binding (and only know a little) after I'd done everything
and it would be a mass of work to change them all now. Do you mind checking
this over to see if it uses early or late binding?

TIA

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

.To = .Recipients.Add(Me.RespPersonEmail)
.Subject = "Query to follow up - CRD " & Me![pkCRDNumber]

End With

OlkMsg.Display

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub
 
D

Douglas J Steele

You're using an intrinsic constant olMailItem in the line

Set OlkMsg = Olk.CreateItem(olMailItem)

You'll need to find out what that value is (sorry, I don't have Outlook on
this machine, so I can't tell you what it should be!).

You'll also need to change the lines

Dim Olk As Outlook.Application
Dim OlkMsg As Outlook.MailItem

to

Dim Olk As Object
Dim OlkMsg As Object

Once you've done that, remove the reference, and see whether it works.

What is OlkRecip? There's no declaration for it in the code you've shown.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


albycindy said:
What you've suggested is very similar to the code I already have. I read
about early/late binding (and only know a little) after I'd done everything
and it would be a mass of work to change them all now. Do you mind checking
this over to see if it uses early or late binding?

TIA

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

.To = .Recipients.Add(Me.RespPersonEmail)
.Subject = "Query to follow up - CRD " & Me![pkCRDNumber]

End With

OlkMsg.Display

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub


Douglas J Steele said:
Whenever you've got a mixed environment like that, where different users can
have different versions of the same product, you're best off using Late
Binding, so that you don't need to set a reference at all.

Rather than having something like:

Dim objOutlook As Outlook.Application

Set objOutlook = New Outlook.Application

you'd use

Dim objOutlook As Object

Set objOutlook = CreateObject("Outlook.Application")

The "trick" is that you need to ensure you're not using any named constants
defined in the Outlook library: you either need to define those constants in
your Access code, or replace the named constants with their actual value.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


this
and Outlook
with referenced
the working
but
 
G

Guest

Thanks for getting back to me on this. I've fixed these and found the
constant for MailItem (0) so I hope it works for every other computer now.

Thanks heaps!

Douglas J Steele said:
You're using an intrinsic constant olMailItem in the line

Set OlkMsg = Olk.CreateItem(olMailItem)

You'll need to find out what that value is (sorry, I don't have Outlook on
this machine, so I can't tell you what it should be!).

You'll also need to change the lines

Dim Olk As Outlook.Application
Dim OlkMsg As Outlook.MailItem

to

Dim Olk As Object
Dim OlkMsg As Object

Once you've done that, remove the reference, and see whether it works.

What is OlkRecip? There's no declaration for it in the code you've shown.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


albycindy said:
What you've suggested is very similar to the code I already have. I read
about early/late binding (and only know a little) after I'd done everything
and it would be a mass of work to change them all now. Do you mind checking
this over to see if it uses early or late binding?

TIA

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

.To = .Recipients.Add(Me.RespPersonEmail)
.Subject = "Query to follow up - CRD " & Me![pkCRDNumber]

End With

OlkMsg.Display

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub


Douglas J Steele said:
Whenever you've got a mixed environment like that, where different users can
have different versions of the same product, you're best off using Late
Binding, so that you don't need to set a reference at all.

Rather than having something like:

Dim objOutlook As Outlook.Application

Set objOutlook = New Outlook.Application

you'd use

Dim objOutlook As Object

Set objOutlook = CreateObject("Outlook.Application")

The "trick" is that you need to ensure you're not using any named constants
defined in the Outlook library: you either need to define those constants in
your Access code, or replace the named constants with their actual value.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have searched through this newsgroup/form thing for information on this
and
tried a few things in the KB article, however I'm still getting a problem.

I have a button on frmFirst with the code to send an email from Outlook
with
a subject line that includes a field from frmFirst. I originally created
this form and coding when I had Outlook 2000 and referenced the library,
Microsoft Outlook 9.0. I recently upgraded to Outlook 2003 and referenced
the
library Microsoft Outlook 11.0.

Both Outlooks are used by staff members (some have 2000, some have 2003 -
everyone has Access 2000). Now, on my computer I can click the button and
open an email quite fine. On a computer with Outlook 2000, it was working
but
since the Object Library 9.0 has disappeared it's not working. But
whatever I
do, I cannot get it to open an email on another computer with Outlook 2003
(get message: ActiveX component can't create object).

I have tried re registering the DAO library.

I have the following libraries referenced in the Visual Basic application:
Visual Basic for Applications
Microsoft Access 9.0 Object Library
Microsoft Outlook 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Office 11.0 Object Library
 

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

Similar Threads

compile error: on CHR (34) 4
ADO -DAO problem 1
What Reference Is Needed? 3
Which reference libraries should i check 2
Run-time error 2287 1
DAO reference 4
Reference Order 3
Stream 1

Top