Trying to write code to check an addin that is currently a reference to a new workbook. Error number 9 continues to haunt me.
Any suggestions would be greatly appreciated.
Oh, and how, exactly, would one include an example of code? I can include it in this message now, but in the future, ya know, I might, ya know, want to do it the right way.
Function IsProc(ProcName) As Boolean
Dim MyModule As Object
Dim MyModuleName As String
Dim MyLine As Long
Dim FoundIT As Boolean
On Error GoTo WTF
If LCase(Left(ProcName, 2)) = "tb" Then
'This next line is the doorstop:
For Each MMN In AddIns("JGM ToolBox.xla").VBProject.VBComponents
MyModuleName = MMN.Name
Set MyModule = AddIns("JGM ToolBox.xla").VBProject.VBComponents(MyModuleName).CodeModule
MyLine = MyModule.ProcStartLine(ProcName, vbext_pk_Proc)
If MyLine <> 0 Then FoundIT = True Else FoundIT = False
If FoundIT Then Exit For
Next
Else
For Each MMN In ActiveWorkbook.VBProject.VBComponents
MyModuleName = MMN.Name
Set MyModule = ActiveWorkbook.VBProject.VBComponents(MyModuleName).CodeModule
MyLine = MyModule.ProcStartLine(ProcName, vbext_pk_Proc)
If MyLine <> 0 Then FoundIT = True Else FoundIT = False
If FoundIT Then Exit For
Next
End If
IsProc = FoundIT
Exit Function
WTF:
MsgBox "Error Number: " & Err.Number & ", " & Error
Resume Next
End Function
Any suggestions would be greatly appreciated.
Oh, and how, exactly, would one include an example of code? I can include it in this message now, but in the future, ya know, I might, ya know, want to do it the right way.
Function IsProc(ProcName) As Boolean
Dim MyModule As Object
Dim MyModuleName As String
Dim MyLine As Long
Dim FoundIT As Boolean
On Error GoTo WTF
If LCase(Left(ProcName, 2)) = "tb" Then
'This next line is the doorstop:
For Each MMN In AddIns("JGM ToolBox.xla").VBProject.VBComponents
MyModuleName = MMN.Name
Set MyModule = AddIns("JGM ToolBox.xla").VBProject.VBComponents(MyModuleName).CodeModule
MyLine = MyModule.ProcStartLine(ProcName, vbext_pk_Proc)
If MyLine <> 0 Then FoundIT = True Else FoundIT = False
If FoundIT Then Exit For
Next
Else
For Each MMN In ActiveWorkbook.VBProject.VBComponents
MyModuleName = MMN.Name
Set MyModule = ActiveWorkbook.VBProject.VBComponents(MyModuleName).CodeModule
MyLine = MyModule.ProcStartLine(ProcName, vbext_pk_Proc)
If MyLine <> 0 Then FoundIT = True Else FoundIT = False
If FoundIT Then Exit For
Next
End If
IsProc = FoundIT
Exit Function
WTF:
MsgBox "Error Number: " & Err.Number & ", " & Error
Resume Next
End Function