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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add an object reference in code.

Status
Not open for further replies.

johnster

Programmer
Jan 3, 2001
9
GB
Does anyone know how to add a reference to an object in code.

Thanks in advance

John.
 
I'm not sure if this is what you want, but I wrote this VBA module to automatically add a reference in Access to the Outlook object library.

Function AddOutlookOleObjectLibrary() As String
' This subroutine automatically adds the Microsoft Outlook 9.0 Object Library
Dim r As Reference, r1 As Reference
Dim s As String, bExists As Boolean
bExists = False

For Each r In Application.References
If r.Name = "Outlook" Then
bExists = True
Exit For
End If
Next

If bExists Then
AddOutlookOleObjectLibrary = "Outlook Library References already exist."
Else
'Get file location
s = SysCmd(acSysCmdAccessDir) & "Msoutl9.olb"

' Add the Reference for The Outlook Object Library
References.AddFromFile s

For Each r In Application.References
If r.Name = "Outlook" Then
AddOutlookOleObjectLibrary = "Outlook Library References Added."
End If
Next

End If

End Function

This is part of a larger module ("Access 2000 SendMessage Function") you can view and download from my computing page.

Terry L. Broadbent - Salt Lake City, UT
Home of the 2002 Winter Olympics (Feb 8-24)
 
Does any one knows how to open Access (2000) databse from VB project without having MS Access Installed on the computer?
I have beeb told to make a reference to "Microsoft Access 10.0 Object Library", but the project still giving me "ActiveX component can not create object" and here is the code:

Function OLEOpenReport(strDBName As String, _
strRptName As String, Optional ByVal intDisplay As Variant, Optional ByVal strFilter As Variant, Optional ByVal strWhere As Variant) As Boolean

On Error GoTo OLEOpenReport_Err

' Create Automation object.
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
 
Kotb,

Please create a new thread for new questions. Your question is not related to the topic of this thread. You want to ask the question in a VB forum.

BTW: Access 2000 uses the Microsoft Access 9.0 Object Library. Terry L. Broadbent - Salt Lake City, UT
Home of the 2002 Winter Olympics (Feb 8-24)
 
Thanks for you help Terry. It looks to be exactly what i want.

Cheers,

John.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top