ModExist Function

 

This function test to see if a given VBA module exists in the current project.

See our White Paper concerning the ‘Dynamic Icon Bar’

 

Function ModExist(strModName As String) As Boolean

'   Function written by Instant Pages Ltd (2002)

'   Visit us at www.instantpages.ltd.uk

'   This credit MUST stay intact for use

    Dim intVBCcnt As Integer

    Dim intVBDcnt As Integer

    Dim intLC1 As Integer

   Set up count of modules in project

    intVBCcnt = ThisWorkbook.VBProject.VBComponents.Count

    intVBDcnt = 0

   Loop through module names

    For intLC1 = 1 To intVBCcnt

        If ThisWorkbook.VBProject.VBComponents(intLC1).Type = vbext_ct_StdModule Then

            If ThisWorkbook.VBProject.VBComponents(intLC1).Name = strModName Then

                ModExist = True

                GoTo Exit_ModExist

            End If

        End If

    Next intLC1

    ModExist = False

Exit_ModExist:

End Function