如何从VSTO应用程序插件中调用Excel VBA函数 [英] How to Call Excel VBA functions from VSTO Application addin

查看:94
本文介绍了如何从VSTO应用程序插件中调用Excel VBA函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看到了很多使用VBA调用VSTO函数,使用自动化加载项,COM Interop等的示例,但并非相反.

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.

我有一个Excel应用程序VSTO加载项,该加载项仅设计用于仅一个Excel工作簿.该Excel工作簿是Office 2003以来的遗留工作簿,包含许多VBA代码.

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.

如何从VSTO调用这些VBA函数和子对象?

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

推荐答案

您可以使用 Application.Run 方法调用它.例如

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

这篇关于如何从VSTO应用程序插件中调用Excel VBA函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆