List Procdures



Sub ListTheLot()
'this is MRD version works simply
Dim Procs(2000, 2)
Dim VBAEditor As VBIDE.VBE
Dim VC As VBIDE.VBComponent
Dim CM As VBIDE.VBComponent
Dim CMM As CodeModule
Dim pk As vbext_ProcKind
Dim wsSheet As Worksheet
Set VBAEditor = Application.VBE
'scan through all the modules
With VBAEditor.ActiveVBProject

pco = 0

For Each CM In .VBComponents
If CM.Type = vbext_ct_StdModule Then
Modname = CM.Name
'MsgBox Modname
Procs(pco, 0) = Modname

'Exit Sub
' Scan through the code module, looking for procedures.
iLine = 1

Set CMM = CM.CodeModule
Do While iLine < CMM.CountOfLines ' objCode.CountOfLines

sProcName = CMM.ProcOfLine(iLine, pk)
If sProcName <> "" Then
' Found a procedure. Store details, and then skip
' to the end of the procedure.

Procs(pco, 1) = sProcName
pco = pco + 1
iLine = iLine + CMM.ProcCountLines(sProcName, pk)
Else
iLine = iLine + 1

End If

Loop
End If
Set CMM = Nothing
Next CM
End With
'now arrange to dump to sheet
With ThisWorkbook
On Error Resume Next
Set wsSheet = .Sheets("Procedures")
On Error GoTo 0
If wsSheet Is Nothing Then ' add it
.Worksheets.Add(After:=.Worksheets(.Worksheets.Count)).Name = "Procedures"
End If
With .Sheets("Procedures")
.Activate
.Range("A4:C2000").ClearContents
.Range("A4").Resize(pco, 2) = Procs
End With
End With
End Sub