开发者

Call VB method in C# using Interop

Okey here's the开发者_C百科 situation: I've got a microsoft excel macro in vb that I want to call using C#. I've already tried creating a workbook using Microsoft.Office.Interop.Excel, however I don't want to have to run an excel process to run the macro.

So then I thought why not make a vb class library with my code in it so i can still run it and have a clean dll file. It's not needed to keep any sheet related functions since the macro reads a .lua(UTF-8)text file with some advanced regex functions that I just can't get recreated in C#.

Is it possible for me to make the library use interop as well so i can just call the function in my C#? Any examples would be greatly appreciated.


First I assume you are working with VB6 and not VB Script?

I have never worked with VB 6 or earlier, but I think your best be will be to create a COM object and then you can call the COM object from .NET using C#. Here is a quick link I found through BING that I believe will help you get started if this in an option for you.

Walkthrough: Implementing Inheritance with COM Objects (Visual Basic)


I noticed these two statements:

I don't want to have to run an excel process to run the macro

and

the macro reads a .lua(UTF-8)text file with some advanced regex functions that I just can't get recreated in C#

Those two goals are incompatible. The macro relies on excel functions to run. The only way provided by Microsoft to accomplish this is to completely load the Excel app. There is no way to only run the macro.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜