Hi,
I have some code (pasted below) to search the modules in another database for instances of keywords. The code adds a reference to the target database, performs the search, and then removes the reference (References.Remove ref)
The line to remove the reference isn't working for some reason, so as I check one database after another my source DB is having more and more references added. This is creating naming conflicts as I have over 5000 databases to analyse many of which share the same VB Project name.
Can anyone shed any light on why the reference removal isn't working please?
Ed Metcalfe.
Please do not feed the trolls.....
I have some code (pasted below) to search the modules in another database for instances of keywords. The code adds a reference to the target database, performs the search, and then removes the reference (References.Remove ref)
The line to remove the reference isn't working for some reason, so as I check one database after another my source DB is having more and more references added. This is creating naming conflicts as I have over 5000 databases to analyse many of which share the same VB Project name.
Can anyone shed any light on why the reference removal isn't working please?
Code:
Private Function IsCodeAccess() As Boolean
Dim ref As Access.Reference
Dim oVBE As Object
Dim mdl As Object
Dim blnFound As Boolean
Dim StartLine As Long
Dim StartColumn As Long
Dim EndLine As Long
Dim EndColumn As Long
Dim astrKeyWords() As String
Dim pntr As Integer
blnFound = False
astrKeyWords = Split("<keywords list here>", ",")
Set ref = References.AddFromFile(m_dbsToAnalyse.Name)
'To make life easier and lines shorter.
Set oVBE = Application.VBE.VBProjects(ref.Name).VBComponents
'Check each module ...
For Each mdl In oVBE
'for the required procedure ...
StartLine = 1
StartColumn = 1
EndLine = oVBE(mdl.Name).CodeModule.CountOfLines
EndColumn = 60
For pntr = 0 To UBound(astrKeyWords())
If oVBE(mdl.Name).CodeModule.Find(astrKeyWords(pntr), StartLine, StartColumn, EndLine, EndColumn) Then
blnFound = True
GoTo ExitHere
End If
Next pntr
Next
References.Remove ref
ExitHere:
IsCodeAccess = blnFound
End Function
Ed Metcalfe.
Please do not feed the trolls.....