VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsVBPRefReporter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' clsVBPRefReporter: Report COM references for VBP file
Option Explicit

Public Event status(ByVal msg As String)

Public Function header() As String
    header = "VBPPATH" & vbTab & "VBPNAME" & vbTab & "LIBNAME" & vbTab & "LIBGUID" & vbTab & "MAJVERS" & vbTab & "MINVERS" & vbTab & "LIBPATH"
End Function

Public Sub processFile(fil As Scripting.File, rpt As Scripting.TextStream)
    
    Const FUNC_NAME$ = "processFile"
    On Error GoTo errorHandler
    
    Dim filpath As String: filpath = fil.ParentFolder.Path
    Dim filname As String: filname = fil.name
    Dim libname As String: libname = "-"
    Dim libguid As String: libguid = "-"
    Dim majvers As String: majvers = "-"
    Dim minvers As String: minvers = "-"
    Dim libpath As String: libpath = "-"
    
    Dim fileSys As FileSystemObject
    Set fileSys = New FileSystemObject
    
    Dim txtfil As Scripting.TextStream
    Set txtfil = openInputText(fil.Path, fileSys)
    
    Dim s As String
    s = txtfil.ReadAll()
    
    Dim arr() As String
    arr = Split(s, vbCrLf)
    
    Dim v As Variant
    For Each v In arr
        
        Dim sLine As String
        sLine = LCase$(v)
        
        Dim inp() As String
        Dim i As Integer
        
        libguid = ""
        If sLine Like "reference=*" Then
            inp = Split(sLine, "#")
            If UBound(inp) = 4 Then
                libguid = inp(0)
                i = InStr(libguid, "{")
                libguid = Mid$(libguid, i)
                majvers = inp(1)
                minvers = inp(2)
                libpath = inp(3)
                libname = inp(4)
            End If
        ElseIf sLine Like "object=*" Then
            inp = Split(sLine, "#")
            If UBound(inp) = 2 Then
                libguid = inp(0)
                i = InStr(libguid, "{")
                libguid = Mid$(libguid, i)
                majvers = inp(1)
                minvers = inp(2)
                inp = Split(minvers, ";")
                minvers = inp(0)
                libpath = Mid$(inp(1), 2)
                libname = libpath
            End If
        End If
        
        If Len(libguid) > 0 Then
        
            Call writeRpt(rpt, _
            filpath & vbTab & _
            filname & vbTab & _
            libname & vbTab & _
            libguid & vbTab & _
            majvers & vbTab & _
            minvers & vbTab & _
            libpath & vbCrLf)
        
        End If
    
    Next v
    
errorHandler:
    
    If Not txtfil Is Nothing Then txtfil.Close
    Set fileSys = Nothing
    Set txtfil = Nothing
    
    If Err Then _
        Err.Raise Err.Number, Description:=TypeName(Me) & "::" & FUNC_NAME$ & " " & _
        vbCrLf & "[" & fil.Path & "]" & _
        vbCrLf & Err.Description
        
End Sub




