private void RunMacro(Application xlApp, Workbook xlWB, string MacroName, out string status) { Worksheet xlWS; status = string.Empty; if (xlApp != null) { xlWS = (Excel.Worksheet)xlWB.Worksheets.get_Item("Sheet1");// .get_Item(paramsExcelOperatios.WorksheetNo); if (MacroName != String.Empty) { xlWS.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, xlApp, new Object[] { MacroName }); } else { status = "Failure - Macro name should not be empty"; } } else { status = "Failure - Worksheet name is not valid."; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)