ProcStartLine, ProcBodyLine, ProcCountLines Properties Example
The following function prints information about a specified procedure in a module to the Debug window:
Function ProcLineInfo(strModuleName As String, _
strProcName As String)
Dim mdl As Module
Dim lngStartLine As Long, lngBodyLine As Long
Dim lngCount As Long, lngEndProc As Long
' Open specified Module object.
DoCmd.OpenModule strModuleName
' Return reference to Module object.
Set mdl = Modules(strModuleName)
' Count lines in procedure.
lngCount = mdl.ProcCountLines(strProcName, vbext_pk_Proc)
' Determine start line.
lngStartLine = mdl.ProcStartLine(strProcName, vbext_pk_Proc)
' Determine body line.
lngBodyLine = mdl.ProcBodyLine(strProcName, vbext_pk_Proc)
Debug.Print
' Print all lines in procedure preceding body line.
Debug.Print "Lines preceding procedure " & strProcName & ": "
Debug.Print mdl.Lines(lngStartLine, lngBodyLine - lngStartLine)
' Determine line number of last line in procedure.
lngEndProc = (lngBodyLine + lngCount - 1) _
- Abs(lngBodyLine - lngStartLine)
' Print all lines in body of procedure.
Debug.Print "Body lines: "
Debug.Print mdl.Lines(lngBodyLine, (lngEndProc - lngBodyLine) _
+ 1)
End Function
You could call this function from the Northwind sample database with a procedure such as the following:
Sub GetProcInfo()
ProcLineInfo "Utility Functions", "IsLoaded"
End Sub