How to pass VBA Collection to/from VBA macro when calling from C#?

G

Gary McGill

I have a COM add-in written in c# that calls a VBA macro embedded in a Word
document. (It invokes the "Run" method of the application object using
InvokeMember).

I can successfully pass simple parameters (string, etc.) and receive a
simple return value but what I'd really like to do is pass & return a
Collection (as in, VBA's definition of a Collection). Is this possible? Is
it safe?

I tried adding a reference to MSVBVM60.DLL to my project, and that looked
like it would allow me to create objects of type VBA.Collection. However, I
don't know if this is the right way to do it. Also, my project wouldn't
build since I got an error about the VBA.Interop.dll not being strong-named.
Is there a PIA for the VBA stuff that I should be using? Should I be
creating my own interop DLL and strong-naming it myself?

All pointers gratefully received,

Gary
 
G

Gary McGill

Rob,

Thanks for your reply. As it happens, I've been reading elsewhere that you
can't create a VB6 Collection outside of VB6 (apparently it's a private
class) - so even if I add the assembly I can't actually do what I wanted. Oh
well...

Gary
 
G

Gary McGill

Robert,

Since I want to pass the Collection into a VBA macro, I don't think I can
use anything other than a VB intrinsic type.

Gary
 

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