1

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:(

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Everything Matters
  • 2,672
  • 4
  • 25
  • 42

2 Answers2

0

Althought your question is not very straight-forward, I think that the links below will assist you in getting the solution to your problem.

First, I found a forum post explaining the same type of error you explain, "Cannot find Macro".

Second, if that doesn't work try researching using the links provided below:

If this does not solve your problem, please edit your question to include additional information.

Allen Gammel
  • 396
  • 2
  • 4
0

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.

Community
  • 1
  • 1
Everything Matters
  • 2,672
  • 4
  • 25
  • 42