Procnames Function
This
function will return an array of procedure names from a given module.
See our
White Paper concerning the ‘Dynamic Icon Bar’
Function ProcNames(ByRef strMName As String) As
String()
' Function written
by Instant Pages Ltd (2002)
' Visit us at www.instantpages.ltd.uk
' This credit MUST stay intact for use
' Function to return the names of Procedures
in a given module
Dim lngSLine As
Long ' Line Number
Dim vbCodeMod As CodeModule ' Object for Code Module
Dim intPCount As
Integer ' Procedure Count
Dim pnamearray() As String
' Procedure Names Array
' Set named module as module object
Set vbCodeMod = ThisWorkbook.VBProject.VBComponents(strMName).CodeModule
' Scan through module looking for Declaration
lines
' and set up array of
macro names as we go
With vbCodeMod
lngSLine
= .CountOfDeclarationLines + 1
Do Until lngSLine
>= .CountOfLines
intPCount = intPCount + 1
ReDim
Preserve pnamearray(intPCount)
pnamearray(intPCount) = .ProcOfLine(lngSLine, vbext_pk_Proc)
lngSLine = lngSLine + .ProcCountLines(.ProcOfLine(lngSLine, vbext_pk_Proc), vbext_pk_Proc)
End With
' Return array of Procedure names
ProcNames = pnamearray()
End Function