Public Function GetModules() As String
On Error GoTo Err_Handler
Dim VBAEditor As VBIDE.VBE
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Dim NumLines As Long
Dim ProcName As String
Dim ProcKind As VBIDE.vbext_ProcKind
Set VBAEditor = Application.VBE
Set VBProj = VBAEditor.ActiveVBProject
For Each VBComp In VBProj.VBComponents
Set CodeMod = VBComp.CodeModule
If GetModules = "" Then
GetModules = "'" & CodeMod.Name & "'"
Else
GetModules = GetModules & ";'" & CodeMod.Name & "'"
End If
Next VBComp
Exit_Handler:
Exit Function
Err_Handler:
MsgBox "Error " & Err.Number & " in ListAllStandardProcedures : " & Err.Description
GoTo Exit_Handler
End Function
Public Function GetProcedures(strModule As String) As String
On Error GoTo Err_Handler
Dim VBAEditor As VBIDE.VBE
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Dim NumLines As Long
Dim ProcName As String
Dim ProcKind As VBIDE.vbext_ProcKind
Set VBAEditor = Application.VBE
Set VBProj = VBAEditor.ActiveVBProject
Set VBComp = VBProj.VBComponents(strModule)
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CountOfDeclarationLines + 1
Do Until LineNum >= .CountOfLines
ProcName = .ProcOfLine(LineNum, ProcKind)
LineNum = .ProcStartLine(ProcName, ProcKind) + _
.ProcCountLines(ProcName, ProcKind) + 1
If GetProcedures = "" Then
GetProcedures = "'" & ProcName & "'"
Else
GetProcedures = GetProcedures & "; '" & ProcName & "'"
End If
Loop
End With
Exit_Handler:
Exit Function
Err_Handler:
If Err = 9 Then
MsgBox "Module does not exist", vbCritical, "No such module"
Else
MsgBox "Error " & Err.Number & " in ListProcedures : " & Err.Description
End If
GoTo Exit_Handler
End Function