I'm using C# to instantiate Excel on server side.
Excel version is 9.0
Below is the code written for Excel.
Excel.Applicati onClass oXL = new Excel.Applicati onClass();
oXL.WindowState =Excel.XlWindow State.xlMaximiz ed;
oXL.ShowWindows InTaskbar =true;
//oXL.WindowActiv ate +=Microsoft.Off ice.Interop.Exc el.AppEvents_Wi ndowActivateEve ntHandler;
//oXL.Windows =Microsoft.Offi ce.Interop.Exce l.Windows;
oXL.EnableEvent s=true;
oXL.Visible=tru e;
//oXL.ShowStartup Dialog=true;
//oXL.DisplayExce l4Menus = true;
int hwndExcel;
oXL.Visible=tru e;
oXL.WindowState =Excel.XlWindow State.xlMaximiz ed;
oXL.Caption = "Some Caption For Excel Window";
hwndExcel = MyApi.FindWindo w("XLMAIN",oXL. Caption);
string Excelstr1 = hwndExcel.ToStr ing();
System.Diagnost ics.Process [] processArr2=Sys tem.Diagnostics .Process.GetPro cessesByName("E xcel");
int process2cnt,pro cessid=100000;
for(process2cnt =0;process2cnt< processArr2.Len gth;process2cnt ++)
{
if(processArr2[process2cnt].MainWindowHand le.ToString()== Excelstr1)
{
processid=proce ssArr2[process2cnt].Id;
//processArr2[process2cnt].Kill();
break;
}
}
// Form1 oform1 =new Form1();
//pid=oform1.GetP rocessID(oXL);
//ewclass oewclass =new ewclass();
//pid=oewclass.Ge tProcessID(oXL) ;
if(pid!=100000)
//{
Process.GetProc essById(pid).Ki ll();
}
}
*************** *************** *************** *************** **********
Sent via Fuzzy Software @
http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...