Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary McGill - 15 Sep 2005 11:27 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.