Discussion Locked

Missing Outlook ref in Access 97/2k/XP

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have written a module in an Access 97 database which has then been used in Access 2k/XP databases to allow users to initiate Outlook and merge Access fields into an email for sending out standard receipts.

The code works fine but there is one problem. Occassionally the reference to the Outlook dll is marked as missing and the code crashes due to this. I have tried placing the dll's in a network location and referencing them there in case they were being updated by IT. This has made no difference. Can anyone help as I am now under pressure to stabilise the systems?

5 replies

by charles byrne

Have you tried the network reference using a UNC name (\\Server\Shared\folder_location\some.dll) instead of a drive mapping?

A work around is to not have a reference set and create the object at run-time. In your code you'd need the following:
--------------------------------------------
Dim OL_App As Object
Dim OL_Itm As Object

Set OL_APP = CreateObject("Outlook.Application")

For x = 1 to ...
Set OL_Itm = OL_APP.CreateItem(olMailItem)

With OL_Itm
.To = YOURACCESS FIELD
.Subject = YOUR ACCESS FIELD
.Body = YOUR ACCESS FIELD
' .Display 'If you prefer
' .UserControl = True 'If you prefer
.Send
End With
Next x

... other code

Set OL_Itm = Nothing
Set OL_APP = Nothing
End Sub

---------------------------------------------

You'll need to do error checking to make sure the
outlook object gets created. And any declaration involving an outlook item will need to be declared as an object.

Hope this helps.
Charles

This discussion is closed to new replies.