3

I have tried using the following code to run excel regression analysis on the specified range of data. I am getting a com inter-op exception:

Cannot run the macro 'C:\Program Files\Microsoft Office\Office14\Library\Analysis\ATPVBAEN.XLAM!Regress'

The macro may not be available in this workbook or all macros may be disabled.

I am not sure how to programmatically enable the add in. This is my solution :

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);
Javed Akram
  • 15,024
  • 26
  • 81
  • 118
AndyMM
  • 880
  • 2
  • 9
  • 20

0 Answers0