How to Reference a .Net Assembly from within VBA?

T

TCook

Hey All,

I want to create an assembly in .Net that I can reference and use in VBA.

I have a sample assembly that I've strongly named and that is loaded in the
GAC. However, I can not see from within VBA.

Please advise?

Thanks & Regards,

TC
 
S

Scott M.

You don't reference .NET assemblies from COM applications. You'll need to
register you .NET assembly for COM InterOp and then re-build it. This will
create a COM Callable Wrapper assembly that you would then reference from
your VBA project as normal.
 
H

Herfried K. Wagner [MVP]

TCook said:
I want to create an assembly in .Net that I can reference and use in VBA.

I have a sample assembly that I've strongly named and that is loaded in
the
GAC. However, I can not see from within VBA.

You can implement the functionality in a .NET class library and expose the
functionality for COM interop:

..NET Framework Developer's Guide -- Exposing .NET Framework Components to
COM
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp>

Visual Basic Language Concepts -- COM Interop
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconCOMInteroperability.asp>
 
T

TCook

Hey Guys,

Thanks for the advice. I figured out my problem. Although I had the class
tagged as a COM class and also had the assembly strongly named, I hadn't
signed the project or registered it for COM interop from within the
project's settings.

Once I signed and registered the assembly and rebuilt it, I was able to use
it from within VBA.

Thanks for the advice.

Best,

TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top