c#中如何操作一个,手动打开的excel,进行另存为的操作Saveas()方法

解决方案 »

  1.   

    Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
                excelApp.Visible = false;
                excelApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application") as Excel.Application;
                
                MessageBox.Show(excelApp.Workbooks.Count.ToString());            string workbookPath = @"E:\11\11.xls";            object missing = System.Reflection.Missing.Value;
                excelApp.ActiveWorkbook.SaveAs(workbookPath, missing, missing, missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing); 自己找到答案了,嘎嘎
      

  2.   

    用getobject和findwindow这些api吧。
    检查是不是运行中,然后sendmessage吧