Hi Paul
Tx for responding - I think you are probably right - the current declarations are:
Public Sub SendMessage(DisplayMsg As Boolean, emailaddr As String, Subject As String, MSG As String, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
That kind of assumes it already knows where Outlook.Application is to be found.
As I understand it - to change this to late binding I need to change the first declaration to just
Dim objOutlook As Object
But what do I change the other declarations to
Dim objOutlookMsg As ?
Dim objOutlookRecip As ?
Dim objOutlookAttach As ?
I presume the subsequent code should remain as is -
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(emailaddr)
objOutlookRecip.Type = olTo
.Subject = Subject
.Body = MSG
.Importance = olImportanceHigh 'High importance
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
etc
---------------------------------------------
OK - I changed the other declarations to Object as well
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object
This worked fine on my system running on full Access 2007 with Outlook 2007 but when compiled and run on the user's system with 2007 Runtime & Outlook 2010 it still comes up with the same error: Application-defined or Object-defined error.
I have traced the error on the user's system to the statement:
Set objOutlookRecip = .Recipients.Add(emailaddr)
that is where it falls over.
I have checked the user's system and the library MSOUTL.OLB only appears in the Office14 folder i.e. the file is not present in the Office12 folder - could it have something to do with the library file?
Thanks
chaver