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
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