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

解决方案 »

  1.   

    打开Excel讲到DataSet中:
    http://blog.csdn.net/chengking/archive/2005/11/29/539514.aspx
      

  2.   

    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.
      

  3.   

    很简单,通过EXCEL对象的Run方法执行Excel文件里的过程(也可以是宏):
    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); 这里的objExcel是你实例化的:Excel.Application
      

  4.   

    关键是,我想问一下。我如果把这个程序放到另外一台电脑。处理不同的excel表,这个宏是不是每台电脑里的操作的每个excel表都要重新写宏