Running A2003 in A2007 runtime

B

Bill

I have a A2003 application compiled and running in a
A2007 environment. The class module for one of the
forms sends an e-mail using the Outlook object model,
(code below). My code runs fine for both Outlook and
Outlook Express while in a 2003 runtime environment,
but in the 2007 runtime environment I get a runtime error
#438: Object doesn't support this property or method.

(I've flagged the statement that caused the error,
Set objOutlookAttach)

I thought at first it might be a reference library issue, but
see that I had long since referenced:
Microsoft Outlook 12.0 Object Library
(Actually, in the 2003 environment the reference shows
as 11.0 and in the 2007 enviroment it shows as 12.0.)

Do I need another reference for the 2007 environment?

Thanks,
Bill

Sub SendMessage(SendTO, SendCOPY, sendBCC, textSubject As String, textBody
As String, _
DisplayMsg As Boolean, Optional AttachmentPath1, Optional
AttachmentPath2, Optional AttachmentPath3)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.

Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(SendTO)
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
If Not IsNull(SendCOPY) Then
Set objOutlookRecip = .Recipients.Add(SendCOPY)
objOutlookRecip.Type = olCC
End If

' Add the BCC recipient(s) to the message.
If Not IsNull(Nz(sendBCC, Null)) Then
Set objOutlookRecip = .Recipients.Add(sendBCC)
objOutlookRecip.Type = olBCC
End If

' Set the Subject, Body, and Importance of the message.
.Subject = textSubject
.Body = textBody & vbCrLf & vbCrLf
' .Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath1) Then
ERROR HERE >>>>> Set objOutlookAttach = .Attachments.Add(AttachmentPath1)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath2)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath3)
End If
End If
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Send
End If

End With
Set objOutlook = Nothing
End Sub
 
B

Bill

The plot thickens! By the way, I inherited the posted code
and not being well versed in the use of object models, I'm
really operating with one arm tied behind my back.

Anyway, after some digging into the history of "this" code,
I find it was originally created in A2000 and runs okay in
the A2003 runtime environment PROVIDED that it is
compiled with reference to Microsoft Outlook 9.0 Object
Library. However, when compiled with the 11.0 verion of
the Outlook Object Library, I get the originally posted
error code and message.

Assuming I can resolve this problem by obtaining a copy
of the 9.0 Object Library, can anyone tell me how to get
a copy and where does it get loaded? Or, am I "barking
up the wrong tree"?

Any help would be greatly appreciated.

Thanks,
Bill
 
G

Gina Whipp

Bill,

Please post the other References... let's see if we can solve this!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

The plot thickens! By the way, I inherited the posted code
and not being well versed in the use of object models, I'm
really operating with one arm tied behind my back.

Anyway, after some digging into the history of "this" code,
I find it was originally created in A2000 and runs okay in
the A2003 runtime environment PROVIDED that it is
compiled with reference to Microsoft Outlook 9.0 Object
Library. However, when compiled with the 11.0 verion of
the Outlook Object Library, I get the originally posted
error code and message.

Assuming I can resolve this problem by obtaining a copy
of the 9.0 Object Library, can anyone tell me how to get
a copy and where does it get loaded? Or, am I "barking
up the wrong tree"?

Any help would be greatly appreciated.

Thanks,
Bill
 
B

Bill

Many thanks Gina,

The reference set is as follows:

Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Outlook 11.0 Object Library
Microsoft Word 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Calendar Control 11.0
OLE Automation

I'm loosing whatever sense I might have had earlier
about library references being at cause here. The
object browser is pretty clear about the properties
and methods for Outlook. Hopefully, you'll get a
thought here that will get us going in the right
direction.

Thanks again,
Bill
(West coast USA)
 
B

Bill

Gina,
I managed to get my hands on the original A2000
application and ran it "as is" in a A2003 runtime
environment without any difficulties, i.e., Outlook
launched normally without errors.

I then un-checked the Outlook 9.0 Library and
browsed in Windows\etc ecc\ for the MSOUTL
module so that I could reference the 11.0 version
of the library. The application ran normally using
version 11.0 reference library.

So, my growing sense that references aren't the
culprit seems to have been confirmed, which
brings me full circle to where I started, namely
I don't have a clue what could be causing the
failure.

Bill
 
G

Gina Whipp

Bill,

Let's start with, see my notes between the <<< >>>

Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Outlook 11.0 Object Library
Microsoft Word 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library <<<look for the 2.5 library>>>
Microsoft Calendar Control 11.0
OLE Automation <<< move this up to the third from the top>>>

1. What is the error message?
2. Do you get it whether you have an attachment or not?
3. Do you get a message from Outlook when trying to send?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Many thanks Gina,

The reference set is as follows:

Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft Outlook 11.0 Object Library
Microsoft Word 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Calendar Control 11.0
OLE Automation

I'm loosing whatever sense I might have had earlier
about library references being at cause here. The
object browser is pretty clear about the properties
and methods for Outlook. Hopefully, you'll get a
thought here that will get us going in the right
direction.

Thanks again,
Bill
(West coast USA)
 
G

Gina Whipp

Bill,

Did you happen to notice any differences in the code? Oh, and if you're
trying to run this in Access 2007 is it in a Trusted Location?

http://www.regina-whipp.com/index_files/TrustedLocation.htm

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina,
I managed to get my hands on the original A2000
application and ran it "as is" in a A2003 runtime
environment without any difficulties, i.e., Outlook
launched normally without errors.

I then un-checked the Outlook 9.0 Library and
browsed in Windows\etc ecc\ for the MSOUTL
module so that I could reference the 11.0 version
of the library. The application ran normally using
version 11.0 reference library.

So, my growing sense that references aren't the
culprit seems to have been confirmed, which
brings me full circle to where I started, namely
I don't have a clue what could be causing the
failure.

Bill
 
B

Bill

1) OLE Automation now 3rd from the top
2) Now using ActiveX Data Objects 2.5 Library
3) Code runs okay without any attachments (i.e., null)

Error code always the same with attachment.
#438: Object doesn't support this property or method.

Code running in A2003 runtime environment now. HOWEVER,
ultimately A2007 runtime WILL BE primary host.

Bill
 
B

Bill

The only difference between the original code and what
was posted is that the attachments are code as required
in the Sub, whereas I've made them optional. Original
check is for Not IsNull, and I changed the test statement
to Not IsMissing. I changed it back to the original, but code
still fails.

Bill
 
B

Bill

WOW! Even this simple code (snippet) fails
with the same error.

Dim objOLApp As Outlook.Application
Dim objOLMail As Outlook.MailItem
(snip)
Case "Microsoft Outlook"

'SendMessage Me.DistTO, Null, Null, Me.DistSubj,
Me.DistBody, False, Me.DistZIPName

'The SendMessage call replaced with the following code

Set objOLApp = CreateObject("Outlook.Application")
Set objOLMail = objOLApp.CreateItem(olMailItem)

With objOLMail
.To = Me.DistTO
.Subject = Me.DistSubj
.Body = Me.DistBody
Fails here > .Attachments.Add Me.DistZIPName, olByValue, 1
.Send
End With

Set objOLMail = Nothing
Set objOLApp = Nothing
 
G

Gina Whipp

Bill,

What are the References in Access 2007 and is it in a Trusted Location?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

WOW! Even this simple code (snippet) fails
with the same error.

Dim objOLApp As Outlook.Application
Dim objOLMail As Outlook.MailItem
(snip)
Case "Microsoft Outlook"

'SendMessage Me.DistTO, Null, Null, Me.DistSubj,
Me.DistBody, False, Me.DistZIPName

'The SendMessage call replaced with the following code

Set objOLApp = CreateObject("Outlook.Application")
Set objOLMail = objOLApp.CreateItem(olMailItem)

With objOLMail
.To = Me.DistTO
.Subject = Me.DistSubj
.Body = Me.DistBody
Fails here > .Attachments.Add Me.DistZIPName, olByValue, 1
.Send
End With

Set objOLMail = Nothing
Set objOLApp = Nothing
 
B

Bill

Gina,

This is failing in an A2003 runtime environment. I wasn't
inclined to ship the application to the A2007 computer
until I could resolve the issues we've been exploring.

I'm not familiar with "Trusted Location" in the context of
Access. Is that a property of the Access Security Options?

Bill
 
G

Gina Whipp

Bill,

http://www.regina-whipp.com/index_files/TrustedLocation.htm

And this could easily be why the code is failing in Access 2007. Did you
say it now works in 2003?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina,

This is failing in an A2003 runtime environment. I wasn't
inclined to ship the application to the A2007 computer
until I could resolve the issues we've been exploring.

I'm not familiar with "Trusted Location" in the context of
Access. Is that a property of the Access Security Options?

Bill
 
B

Bill

No. It fails the same way in A2003


Gina Whipp said:
Bill,

http://www.regina-whipp.com/index_files/TrustedLocation.htm

And this could easily be why the code is failing in Access 2007. Did you
say it now works in 2003?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina,

This is failing in an A2003 runtime environment. I wasn't
inclined to ship the application to the A2007 computer
until I could resolve the issues we've been exploring.

I'm not familiar with "Trusted Location" in the context of
Access. Is that a property of the Access Security Options?

Bill
 
G

Gina Whipp

Bill,

Just realized IsMissing() actually returns "" for a string and that might be
causing the problem. Why did you change that instead of leaving Not IsNull?
I would suggest changing it back.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

The only difference between the original code and what
was posted is that the attachments are code as required
in the Sub, whereas I've made them optional. Original
check is for Not IsNull, and I changed the test statement
to Not IsMissing. I changed it back to the original, but code
still fails.

Bill
 
B

Bill

Amongst all the things I tried included that very issue, so I changed the
code accordingly a day or so ago. The code currently reads as follows:

If Not IsNull(AttachmentPath1) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath1)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath2)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath3)
End If
End If
End If

It's failing on the 1st "Set" statement, as it has been all along on both
A2003
and A2007 runtime environments.

I will likely make the other two path expressions required parameters also
once the major issue is resolved.

Bill
 
G

Gina Whipp

Bill,

But you haven't change all the IsMissing() functions. Try that as Access
sometimes fails on the line before the actual problem. Also, why are you
using Set for each line? Let's try...

If Not IsNull(AttachmentPath1) Then
.Attachments.Add(AttachmentPath1)
If Not IsIsNull(AttachmentPath2) Then
.Attachments.Add(AttachmentPath2)
If Not IsNull(AttachmentPath2) Then
.Attachments.Add(AttachmentPath3)
End If
End If
End If

Not even sure I like that but let's see how that works...
--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Amongst all the things I tried included that very issue, so I changed the
code accordingly a day or so ago. The code currently reads as follows:

If Not IsNull(AttachmentPath1) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath1)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath2)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath3)
End If
End If
End If

It's failing on the 1st "Set" statement, as it has been all along on both
A2003
and A2007 runtime environments.

I will likely make the other two path expressions required parameters also
once the major issue is resolved.

Bill
 
B

Bill

Same error in the same place with this code:

If Not IsNull(AttachmentPath1) Then
error> .Attachments.Add (AttachmentPath1)
If Not IsNull(AttachmentPath2) Then
.Attachments.Add (AttachmentPath2)
If Not IsNull(AttachmentPath2) Then
.Attachments.Add (AttachmentPath3)
End If
End If
End If
 
G

Gina Whipp

Bill,

That is what I mean by the error message, not always *where* it
highlights... Where is AttachmentPath1, etc... Is it a field on your form?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Same error in the same place with this code:

If Not IsNull(AttachmentPath1) Then
error> .Attachments.Add (AttachmentPath1)
If Not IsNull(AttachmentPath2) Then
.Attachments.Add (AttachmentPath2)
If Not IsNull(AttachmentPath2) Then
.Attachments.Add (AttachmentPath3)
End If
End If
End If
 

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