Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to register reference programmingly? 1

Status
Not open for further replies.

seaport

MIS
Jan 5, 2000
923
US
How to add Outlook 9.0 object library or Excel 9.0 object libary, or other object libraries and ActiveX control to the reference list programmingly?

Thanks

Seaport
 
This is straight from the ACCESS 97 Help File, always a good place to start looking for examples.

PaulF

The following example creates a reference to a specified type library:

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

On Error GoTo Error_ReferenceFromFile
Set ref = References.AddFromFile(strFileName)
ReferenceFromFile = True

Exit_ReferenceFromFile:
Exit Function

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

You could call this function by using a procedure such as the following, which creates a reference to the calendar control:

Sub CreateCalendarReference()
If ReferenceFromFile("C:\Windows\System\Mscal.ocx") = True Then
MsgBox "Reference set successfully."
Else
MsgBox "Reference not set successfully."
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top