How to Call Excel VBA functions from VSTO Applicat

2019-08-06 09:03发布

Seen a quite a few examples of calling VSTO functions from VBA, using Automation Add-In, COM Interop etc but not the other way round.

I have an Excel application VSTO addin that is only designed to work with only the one Excel workbook. This Excel workbook is a legacy workbook since office 2003 and contains many VBA code.

How can I call these VBA functions and subs from VSTO?

标签: c# excel vba vsto
1条回答
霸刀☆藐视天下
2楼-- · 2019-08-06 09:17

You can call it using the Application.Run method. E.g.

ThisApplication.Run("MyVbaMacroName",
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
查看更多
登录 后发表回答