Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.Net Class Library Collections for COM consumption.

10 views
Skip to first unread message

bob

unread,
Mar 27, 2008, 2:17:20 PM3/27/08
to
I am in the process of creating a class library that is intended for
consumption by VBA in an Excel Workbook. The thought being that this
will create a transition period as we migrate from VBA based solutions
to .Net solutions.

I have not done any COM development before and I am having a couple of
problems. Please forgive me if I have overlooked something simple.

I have explicitly defined the interface for the CCW for each of the
classes I want to be visible, I would like to be able to pass some
collections back into the VBA but I have not been able to define them
in the interface so they are visible in the object browser of the VBA
editor.

Spefically, I have been using List<T> in the C# code, but I willing to
convert them to whatever they need to be so they are recognizable
within the VBA. Does anyone know how I can define my data lists so
they are recognizable with in VBA?

I also realize that another option would be to wrap the list in a sub
class with an IEnumerable interface, but I'm not sure if that would
allow me pass my objects into a collection on the VBA side of the
project. Will presenting the IEnumerable interface allow me to loop
through objects in a collection class from VBA?

I also made the mistake that for awhile I was testing using the
AutoDual attribute to present the class interface, I have since gone
back and created an explicit interface for everything, but I still get
some strange behavior within the VBA editor of Excel. The object
browser will report the correct methods, but the auto complete /
syntaz highlighting in the code window tells a different story and
will contain methods and properties from another class. Will adding a
DispId attribute to the interfaces fix this or is something more
drastic required? Also, is the DispID associated with the interface
or the property / method within the interface?

Sorry about all of the questions and thanks in advance for any help.

Juan Bautista

unread,
Jun 9, 2011, 4:36:38 PM6/9/11
to

Juan Bautista

unread,
Jun 9, 2011, 4:43:27 PM6/9/11
to
This worked for me:

http://stackoverflow.com/questions/6231995/accessing-net-collection-in-vb6

> On Friday, March 28, 2008 3:07 AM bob wrote:

0 new messages