vanhunk
07-09-2013, 07:04 AM
Good day,
The following is code provided by Chip Pearson, my problem is how to apply it to determine if a Procedure called "TestProcedure" is present in one of the modules of the workbook:
From Chip Pearson:
Testing If A VBComponent Exists
This code will return True or False indicating whether the VBComponent named by VBCompName exists in the project referenced by VBProj. If VBProj is omitted, the VBProject of the ActiveWorkbook is used.
Public Function VBComponentExists(VBCompName As String, Optional VBProj As VBIDE.VBProject = Nothing) As Boolean
' This returns True or False indicating whether a VBComponent named VBCompName exists in the VBProject _
referenced by VBProj. If VBProj is omitted, the VBProject of the ActiveWorkbook is used.
Dim VBP As VBIDE.VBProject
If VBProj Is Nothing Then
Set VBP = ActiveWorkbook.VBProject
Else Set VBP = VBProj
End If
On Error Resume Next
VBComponentExists = CBool(Len(VBP.VBComponents(VBCompName).Name))
End Function
I would appreciate any assistance.
I have tried to use it but get "False" even though the procedure does in fact exist!
Thank you
The following is code provided by Chip Pearson, my problem is how to apply it to determine if a Procedure called "TestProcedure" is present in one of the modules of the workbook:
From Chip Pearson:
Testing If A VBComponent Exists
This code will return True or False indicating whether the VBComponent named by VBCompName exists in the project referenced by VBProj. If VBProj is omitted, the VBProject of the ActiveWorkbook is used.
Public Function VBComponentExists(VBCompName As String, Optional VBProj As VBIDE.VBProject = Nothing) As Boolean
' This returns True or False indicating whether a VBComponent named VBCompName exists in the VBProject _
referenced by VBProj. If VBProj is omitted, the VBProject of the ActiveWorkbook is used.
Dim VBP As VBIDE.VBProject
If VBProj Is Nothing Then
Set VBP = ActiveWorkbook.VBProject
Else Set VBP = VBProj
End If
On Error Resume Next
VBComponentExists = CBool(Len(VBP.VBComponents(VBCompName).Name))
End Function
I would appreciate any assistance.
I have tried to use it but get "False" even though the procedure does in fact exist!
Thank you