VBE – Does Procedure Exist Within a Module

Once again, while trying to help someone out in a forum, I came up with the following function to validate whether a procedure exists within a module or not.

'---------------------------------------------------------------------------------------
' Procedure : VBE_Mod_ProcExist
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Determine if a Procedure exists within a module
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
'             (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: Uses Late Binding, so none required
' Compatibility: This is not application specific, so it should work in any VBA project.
'                (tested in Word, Excel & Access)
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sModuleName : Name of the Module that contains the procedure
' sProcName   : Name of the procedure to validate the existance of
'
' Usage:
' ~~~~~~
' ? VBE_Mod_ProcExist("Module1", "fosusername")
' ? VBE_Mod_ProcExist("Form_Form1", "Form_Close")
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2019-01-02              Initial Release, Forum Help
'---------------------------------------------------------------------------------------
Public Function VBE_Mod_ProcExist(ByVal sModuleName As String, _
                                  ByVal sProcName As String) As Boolean
    Dim lProcStart            As Long
    Const vbext_pk_Proc = 0

    On Error GoTo Error_Handler

    lProcStart = Application.VBE.ActiveVBProject.VBComponents(sModuleName). _
                 CodeModule.ProcStartLine(sProcName, vbext_pk_Proc)
    VBE_Mod_ProcExist = True

Error_Handler_Exit:
    On Error Resume Next
    Exit Function

Error_Handler:
    Resume Error_Handler_Exit
End Function
Important
Do pay special attention when validating Forms and Reports as you need to include the Form_ or Report_ prefix and the name of the object.