Calling VBA-Macros with user-defined Types from C#?
I've got a Word Document with a VBA Module that contains user defined Types (public Type XXX) and some public subs that take this Type as arguments. Is it possible to call these subs from C# via Application's Run()?
Greeting开发者_StackOverflow中文版s, Steven
I don't know if you have the flexibility to do this, but here's how I solved this.
- Create another assembly (I called mine "xx.Common")
- Add some structs in there, make them COM-visible
- Reference that assembly from both the VBA and C# projects
- Add a new VBA sub with those structs as arguments
You can now pass in structured, user-defined data. If you generalize this idea, you can use any COM-visible type (i.e. not just structs). As long as both projects reference an assembly that defines these types, you should be ok.
精彩评论