List functions in modules with comments

G

Guest

I have code (from Help) that lists modules and the function or subs in each
module. The Help gives info about the line numbers where the functions
start, but there is no indication how one should loop through the code.

I'm trying to read through 60 or so .MDBs in order to pickup the related
comments. It turns out that I've been diligent about documenting code with
comments, especially a revision history, and I'd like to pick-up that info in
order to ascertain which MDBs contain the current modules (stored centrally
and imported).

Thank you for your thoughts.
 
A

Allen Browne

Is this any use?

Function ListProc(strModuleName As String) As String
Dim mdl As Module
Dim lngCount As Long
Dim lngCountDecl As Long
Dim lngI As Long
Dim strProcName As String
Dim intI As Integer
Dim strMsg As String
Dim lngR As Long

lngR = vbext_pk_Proc

' Open specified Module object.
DoCmd.OpenModule strModuleName
Set mdl = Modules(strModuleName)

lngCount = mdl.CountOfLines
lngCountDecl = mdl.CountOfDeclarationLines

' Determine name of first procedure.
strProcName = mdl.ProcOfLine(lngCountDecl + 1&, lngR)

intI = 0

Debug.Print strProcName, lngR

' Determine procedure name for each line after declarations.
For lngI = lngCountDecl + 1& To lngCount
' Compare procedure name with ProcOfLine property value.
If strProcName <> mdl.ProcOfLine(lngI, lngR) Then
intI = intI + 1&
strProcName = mdl.ProcOfLine(lngI, lngR)
Debug.Print strProcName
Debug.Print , "ProcStartLine = " &
mdl.ProcStartLine(strProcName, lngR)
Debug.Print , "ProcBodyLine " & mdl.ProcBodyLine(strProcName,
lngR)
'ProcBodyLine is the declaration; ProcStartLine is the blank
space above procedure.
End If
Next lngI
End Function
 
G

Guest

Thank you.
It turned out that what I was missing was:
Else
Debug.Print mdl.Lines(lngI, 1)

The Lines property is what I didn't know to look for.
I saw the example you provided in Help, but there was no reference to the
Lines property (unless, of course, you knew where to look, and what to look
for).

Thank you for your service to the community.
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top