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

Checking for Library References using VBA ( & creating them if needed

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
GB
I have one function that I need to implement that requires the "Microsoft ADO Ext. 2.1 for DDL and Security" library reference.

I know that this is not referenced on a vast majority of the machines that this application will run on.

Is there a way to use VBA code to :-

A) Test to see if a reference exists

B) Create the reference if it does not exist

C) Remove a reference when it is no longer needed


G LS
 
The following code will populate a recordset with the references currently defined and whether or not they are broken. (Not sure how to create and remove references)
Code:
    Dim rst As ADODB.Recordset
    Dim ref As Reference
    
'**********************************************
'*  Define new recordsets (arrays basically)  *
'**********************************************

    Set rst = New ADODB.Recordset
    
    rst.Fields.Append "Broken", adVarChar, 6
    rst.Fields.Append "Name", adVarChar, 70
    rst.Fields.Append "FullPath", adVarChar, 255
    rst.Fields.Append "DB", adVarChar, 7
    
    rst.Open
    
'*********************
'*  Build Recordset  *
'*********************

    For Each ref In Application.References
        rst.AddNew Array("Broken", "Name", "FullPath"), Array(IIf(ref.IsBroken, "Broken", "Ok"), ref.Name, ref.FullPath)
    Next

    rst.MoveFirst
    While not rst.eof
       debug.print rst!Broken & rst!Name & rst!FullPath
    Wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top