views:

45

answers:

3

Guys,

How do I reference VBA assembly in C# application from Visual Studio 2010?

I can not find it in "Add Reference" dialog box.

This is the reason why I need it:

Error 1 The type 'VBA.Collection' is defined in an assembly that is not referenced. You must add a reference to assembly 'VBA, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null'. ...

I would really appreciate your help on this one.

Thanks, Ruby

A: 

You really don't need VBA.Collection type in C#, you have much better collection constructs available. Generic.List, Generic.Dictionary etc, if you have a look at those you will most likely find what you need.

These are strongly typed, so you won't be Casting to other types. If you need the VBA "Variant" type, you could use HashTable.

Paul Farry
I agree. But the problem is that the COM I am working with is returning VBA.Collection
Ruby
ah now i get ya
Paul Farry
A: 

An "assembly" is a set of .NET functions packaged in a common DLL or EXE. VBA is not .NET, therefore it does not exist as an assembly. You can, however, access VBA components via the COM Interop layer.

What I think you're probalby looking for is this

http://support.microsoft.com/?kbid=323737

Mystere Man
+2  A: 

There are lots of versions of VBA, integrated in various application. Going by the version number, I'm guessing you need to use Project + Add Reference, Browse tab, select c:\windows\system32\msvbvm60.dll. That's the runtime support module for VB6. It indeed has a Collection class in the VBA namespace.

Do try to double-check if the component was written in VB6. Deployment could be interesting.

Hans Passant