Adding Outlook Redemption Reference Programmatically

C

cseifferly

I am trying to email automatically from Access. Many of our users have
Outlook 2000 or higher and so I need to use Outlook Redemption to get around
the security pop up.

How would I
1: Check to see if the reference has already been added
2: Programmatically add the reference.

I've found code samples for Excel but none for Access.

I'm slightly confused as to how dlls need to be registered. I understand
that Access houses them in the actual database when added, but they still
must reside somewhere in the registry. How would I handle that?

Any suggestions would be much help.
 
D

Douglas J. Steele

To check what references have been set, use:

Sub ListReferences()
Dim refCurr As Reference

For Each refCurr In References
Debug.Print refCurr.Name
Next refCurr

End Sub

I don't use Redemption (we don't use Outlook, for that matter), so I'm not
sure what the actual reference would be, but you should be able to create a
function along the lines of:

Function RedemptionExists() As Boolean
On Error Resume Next

RedemptionExists = References("Redemption").Name = "Redemption"

End Function

(Replace "Redemption" with whatever name the ListReferences routine lists)

To programmatically add a reference, use the AddFromFile method of the
References collection. From the Help file:

Function ReferenceFromFile(strFileName As String) As Boolean
Dim ref As Reference

On Error GoTo Error_ReferenceFromFile
' Create new reference.
Set ref = References.AddFromFile(strFileName)
ReferenceFromFile = True

Exit_ReferenceFromFile:
Exit Function

Error_ReferenceFromFile:
MsgBox Err & ": " & Err.Description
ReferenceFromFile = False
Resume Exit_ReferenceFromFile
End Function

To ensure that the reference has been properly registered, you can use the
DllRegisterServer function. Here's what MichKa has to say about this in
http://www.trigeminal.com/usenet/usenet026.asp:

If any dependent reference is indeed broken, then fix it. Register it (do it
via Declare not by shelling regsvr32 so you can check the return value) or
whatever method is needed. If the file is not in a system directory, you can
use the LoadLibrary/FreeLibrary APIs to load the file prior to calling the
DllRegisterServer function. The syntax for the registration Declaration is:

Declare Function DllRegisterServer Lib "<yourlib.dll>" () As Long

Once you've declared it, you can use code like this to ensure that your file
is registered:

Const ERROR_SUCCESS = &H0

If DllRegisterServer = ERROR_SUCCESS Then
MsgBox "Registration Successful"
Else
MsgBox "Registration Unsuccessful"
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