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
Robert Jordan - 16 Sep 2005 18:05 GMT
Hi Gary,
> 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?
There is no PIA, so you have to sign the interop assembly yourself:
tlbimp MSVBVM60.DLL /keyfile:yourkey.snk
Rob
Gary McGill - 16 Sep 2005 18:19 GMT
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
> Hi Gary,
>
[quoted text clipped - 12 lines]
>
> Rob
Robert Jordan - 16 Sep 2005 18:26 GMT
Hi Gary,
> 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...
Already tried to use a .NET-Collection? For example an ArrayList.
Rob
Gary McGill - 19 Sep 2005 14:32 GMT
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
> Hi Gary,
>
[quoted text clipped - 6 lines]
>
> Rob