I tried using the following code to run excel regression analysis on a specified data range. I get inter-op exception com:
Cannot start macro 'C: \ Program Files \ Microsoft Office \ Office14 \ Library \ Analysis \ ATPVBAEN.XLAM! Regress'
A macro may not be available in this book, or all macros may be disabled.
I am not sure how to programmatically enable the add. This is my decision:
xlApp1 = new Microsoft.Office.Interop.Excel.Application();
xlApp1.AddIns.get_Item("Analysis ToolPak").Installed = true;
xlApp1.Run(@"C:\Program Files\Microsoft Office\Office14\Library\Analysis\ATPVBAEN.XLAM!Regress", yValues, xValues, false, false, Type.Missing, output, false, false, false, false, Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);