日期:2014-05-18  浏览次数:20893 次

怎么在c#里打开一个excel文件然后调用vba代码?请写出详细步骤。分不够再加!!!
怎么在c#里打开一个excel文件然后调用vba代码?请写出详细步骤。分不够再加!!!

------解决方案--------------------
打开Excel讲到DataSet中:
http://blog.csdn.net/chengking/archive/2005/11/29/539514.aspx
------解决方案--------------------
Do you want to invoke the VBA inside the Excel? Or does this VBA a standalone application which has no relation to Excel file?
If you want to invoke the vba inside the excel file.
you can start Excel vba editor and add code into auto_exe part so that whenever you start excel, the vba code will run.
------解决方案--------------------
ExecuteExcel4Macro
------解决方案--------------------
很简单,通过EXCEL对象的Run方法执行Excel文件里的过程(也可以是宏):

C# code

objExcel.Run("Macro1", 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);