To determine if a procedure exists in a referenced addin.

MrJGM

New Member
Joined
Jun 18, 2015
Messages
8
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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
1) see if the code below helps

2) to post code, use the # icon on the message toolbar

Code:
Sub FindProc()
Dim ain$, found As Boolean, cp As VBIDE.VBComponent
ain = AddIns(8).Name                                    ' refer to add-in by index
For Each cp In Workbooks(ain).VBProject.VBComponents
    With cp.CodeModule
        found = .Find("BrowseCallBackFunc", 1, 1, .CountOfLines, 255, True, False, False)
    End With
    If found Then Exit For
Next
MsgBox found
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top