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

How to remove a valid reference

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am creating multiple databases and I need the same references installed on them in the same order. I have a program that will install the references I need. Before I install the references I want I check to see if any references are broken if they are I remove them. I cant figure out how to remove a valid reference so my referece order is correct. I have highlighted the code in question in blue. Any help would be appreciated.

Tom

Code:
Public Function AddRefs()
    Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String
    Dim vbProj As VBProject    ' This refers to your VBA project.
    Dim chkRef As Reference    ' A reference.

    On Error Resume Next
    'Remove existing references
    Dim refCurr As Reference

    'Remove broken references
    For intX = References.Count To 1 Step -1
        Set refCurr = References(intCount)
        If refCurr.IsBroken Then
            References.Remove refCurr
        End If
    Next
    'Remove existing references
[Blue]    For intX = References.Count To 1 Step -1
        Set refCurr = References(intCount)
        If refCurr.BuiltIn Then
            References.Remove refCurr
        End If
    Next [/Blue]

    
    'Add references
    With Access.References
        'VBA (Visual Basic For Applications)
        .AddFromFile "C:\Program Files\Common Files\Microsoft Shared\vba\vba6\vbe6.dll"
        'Access (Microsoft Access 10.0 Object Library)
        .AddFromFile "C:\Program Files\Microsoft Office\Office10\msacc.olb"
        'The Microsoft DAO 3.6 Object Library (DAO360.DLL)
        .AddFromFile "C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll"
        'OLE Automation
        .AddFromFile "C:\WINNT\System32\stdole2.tlb"
        'Microsoft Visual Basic for Application Extensibility 5.3
        .AddFromFile "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
        'Microsoft Office XP Web Components
        .AddFromFile "C:\Program Files\Common Files\Microsoft Shared\Web Components\10\OWC10.dll"
        'Microsoft Excel 10.0 Object Library
        .AddFromFile "C:\Program Files\Microsoft Office\Office10\excel.exe"
        'Microsoft ADO Ext 2.8 for DDL and security
        .AddFromFile "C:\Program Files\Common Files\System\ado\msadox.dll"
        'Microsoft ActiveX Data Objects 2.8 Library Reference
        .AddFromFile "C:\Program Files\Common Files\System\ado\msado15.dll"
    End With
    ' Call a hidden SysCmd to automatically compile/save all modules.
    Call SysCmd(504, 16483)
End Function
 
so my referece order is correct
You don't have to rely to a correct reference order if you never use ambiguous reference in your code...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top