如何从VS运行Excel宏?

Ily*_*okh 6 c# excel

如何从VS2010(C#)运行Excel宏?我使用Microsoft.Office.Interop.Excel命名空间

ama*_*tar 9

试试这篇文章:

http://support.microsoft.com/kb/306683

运行宏的相关部分是这样的(oApp代码中的应用程序实例):

private void RunMacro(object oApp, object[] oRunArgs)
{
    oApp.GetType().InvokeMember("Run",
        System.Reflection.BindingFlags.Default |
        System.Reflection.BindingFlags.InvokeMethod,
        null, oApp, oRunArgs);
}
Run Code Online (Sandbox Code Playgroud)