References Collection Methods






Method. Parameters: FileName As String. Adds a reference between the VBProject and a specific file. This should only be used to create references between workbooks.



Method. Parameters: Guid As String, Major As Long, Minor As Long. Adds a reference between the VBProject and a specific DLL, Typelib, and so forth. A library's filename, location, and version may change over time, but its Guid is guaranteed to be constant. Hence, when adding a reference to a DLL, Typelib, and so on, the Guid should be used. If you require a specific version of the DLL, you can request the major and minor version numbers.


Method. Parameters: Reference As Reference. Removes a reference from the VBProject.

The References collection provides two events, which you can use to detect when items are added to or removed from the collection. You could use this, for example, to create a Top 10 References dialog, by using Application events to detect when a workbook is opened or created and hooking into the References collection of the workbook's VBProject events to detect when a particular Reference is added to a project. You could maintain a list of these and display them in a dialog box, similar to the existing Tools O References dialog in the VBE (but without all the clutter).

0 0

Post a comment