Author: longhorn09 | Posted on: 7/22/2009 5:06:39 PM | Views : 1206

using System; using VBIDE = Microsoft.Vbe.Interop; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Office.Core; namespace TestWeb { public class ExcelUtil { public ExcelUtil() { Excel.Application app = new Excel.Application(); Excel.Workbook workbook = app.Workbooks.Add(1); Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Sheets[1]; Microsoft.Vbe.Interop.VBComponent oModule = workbook.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule); string macroString = "sub RunSolver()\r\n" + " SolverReset \r\n" + " msgbox \"Hello World\"\r\n" + "end sub"; string solverPath = @"c:\program files\microsoft office\OFFICE11\library\SOLVER\SOLVER.XLA"; app.Visible = false; app.AutomationSecurity = M ...

Go to the complete details ...