• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

load analysis toolpak from c# starts up excel

hi all

When c# windows form launches excel the addin analysis toolpak does not load.  I found online this is done on purpose and I have to manually load it.  But it does not seem to be working.

there also is some info about running the automacros on the addin.  But I do not know if the toolpak analysis has automacros.  And if it does I am not able to load it.

any ideas where I am going wrong
public partial class Form1 : Form
    {
        Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
        Workbook file1;
        Workbook file2;
        int columnCount;
        int rowCount;

        public Form1()
        {
            InitializeComponent();
            excelApp.Visible = true;
            

            // Open the add-in file you want, in this example, XLQUERY.XLAM.
            file2 = excelApp.Workbooks.Open(@"C:\Program Files\Microsoft Office\Office14\Library\Analysis\ATPVBAEN.XLAM");
            excelApp.RegisterXLL ("Analys32.xll");
            
            //excelApp.Workbooks// 

            file1 = excelApp.Workbooks.Open(@"C:\Documents and Settings\x152169\Desktop\peer.xlsm", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

Open in new window

0
solarissf
Asked:
solarissf
  • 2
1 Solution
 
solarissfAuthor Commented:
if I throw this in to run automacros

excelApp.Workbooks("ATPVBAEN.XLAM").RunAutoMacros 1;

i get the following error :
Error      3      Only assignment, call, increment, decrement, and new object expressions can be used as a statement      \\njros1ns22\x152169$\my documents\visual studio 2010\Projects\ManagerAnalysis\ManagerAnalysis\Form1.cs      31      63      ManagerAnalysis
0
 
solarissfAuthor Commented:
figured it out:

file2 = excelApp.Workbooks.Open(@"C:\Program Files\Microsoft Office\Office14\Library\Analysis\ATPVBAEN.XLAM");
            excelApp.RegisterXLL ("Analys32.xll");
            file2.RunAutoMacros(XlRunAutoMacro.xlAutoOpen);

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now