Class References (Access VBA)

The References collection contains Reference objects representing each reference that's currently set. To use a References class variable it first needs to be instantiated, for example

AddFromFile

The AddFromFile method creates a reference to a type library in a specified file.

AddFromFile (FileName)

FileName: A string expression that evaluates to the full path and file name of the file containing the type library to which you wish to set a reference.


Dim strFileName As String: strFileName = 
Dim refAddFromFile As Reference
Set refAddFromFile = References.AddFromFile(FileName:=strFileName)

AddFromGuid

The AddFromGUID method creates a Reference object based on the GUID that identifies a type library. Reference object.

The GUID property returns the GUID for a specified Reference object. If you stored the value of the GUID property, you can use it to re-create a reference that's been broken.

AddFromGuid (Guid, Major, Minor)


References.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0

Arguments

The following arguments are required:

Guid (String) - A GUID that identifies a type library.

Major (Long) - The major version number of the reference.

Minor (Long) - The minor version number of the reference.

Count

You can use the Count property to determine the number of items in a specified collection.


References.Count

Item

The Item method returns a specific member of a collection either by position or by key. Reference object.

If the value provided for the var argument doesn't match any existing member of the collection, an error occurs. The Item method is the default member of the References collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent.

Item (var)

var: An expression that specifies the position of a member of the collection. If a numeric expression, the var argument must be a number from 1 to the value of the collection's Count property. If a string expression, the var argument must be the name of a member of the collection.


Debug.Print References(1).Name

Remove

The Remove method removes a Reference object from the References collection.

To determine the name of the Reference object that you wish to remove, check the Project/Library box in the Object Browser. The names of all references that are currently set appear there. These names correspond to the value of the Name property of a Reference object.

Remove (Reference)

Reference: The Reference object that represents the reference that you wish to remove.


Dim ref As Reference: Set ref = 
References.Remove Reference:=ref