Hello,me again,
I have a bunch of excel files with macros,which executes on file open.Macro
connect to the database,refresh itselfs,save results to other workbook and close workbook,another workbook opens,do the same job,closes itself and so on.
c# code for this is:
Code:
Excel.Application excelApp121 = new Excel.Application();
excelApp121.Visible = true;
Excel.Workbooks oBooks121 = excelApp121.Workbooks;
Excel._Workbook oBook121 = null;
oBook121 = oBooks121.Open(@"C:\@IT\Izvestaji\Uzice visual\TOP_50_OBST42.xls", oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
//Run the macros
RunMacro(excelApp121, new Object[] { "auto_open" });
// Quit Excel and clean up.
oBook121.Close(false, oMissing, oMissing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook121);
oBook121 = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks121);
oBooks121 = null;
excelApp121.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp121);
excelApp121 = null;
All works as expected,BUT (Always there is some "but" is possible to integrate
excel files into windows form application,not as separate excel application window.After some googling i found out that this is achieved using webbrowser control,using this control i can open excel file in application but macro wont run,is possile to run macro in webbrowsercontrol and to close it ?