I have a .Net class library and have done all things needed to include it in excel. (expoting as COM visible, for com-interop and regasm’ing the dll as well)
I use excel 2007. In the excel addins, I see my ‘TestLib.Functions’ as checked. I am able to access the function in my VBA code as :
Set lib = New TestLib.Functions
returnVal = lib.Add(5);
This works fine.
For other code review reasons, I also saw some functions from another library accessed using the RUN method as :
Run("avSomeFunction", paramvalue)
Now, in the VBA editor, if I try to access the ‘Add’ function in the same way,
Run("Add", 5)
I get an error saying ‘Cannot find a macro with name Add’. Is it neccesary that I should
add tlb as a reference once again in the VB editot-tools-references again, apart from doing Regasm for the .net dll? Can someone please let me know what is the problem here.
p.s : for some very crazy reason, I just had this working once suddenly but again failed to work there after. very weird:(
Difference between : adding a tlb as reference to invoke function VS using 'Run'? has the answer to this. Basically, I was missing the reference to the tlb in the VBA project. Apart from registering the dll, the tlb also needs to be added as a reference.