In addition to searchign the current model for specific items, it is also often necessary to search on all attached references. The treatment of references in the search, however, is very similar to looking into a model for a reference (attachment in VBA), one type per model.
Here is a small example in which all references are found by looking for lines, and the total number of lines found is output:
Dim Ee As ElementEnumerator
Dim SC As New ElementScanCriteria
Dim oAtt As Attachment
Dim count As Long
count = 0
For Each oAtt In ActiveModelReference.Attachments
Set Ee = oAtt.Scan(SC)
Do While Ee.MoveNext
count = count + 1
MsgBox ("Total: " & count & " lines found in all references")
The For-Next loop runs through all currently open models and their attached references. The variable "count" counts all found lines and is output at the end of the routine.