How to Call Excel VBA functions from VSTO Application addin

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 09:34:56

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/10787373/how-to-call-excel-vba-functions-from-vsto-application-addin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!