load analysis toolpak from c# starts up excel

Posted on 2011-10-13
Last Modified: 2012-06-21
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()
            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");

            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

Question by:solarissf

    Author Comment

    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

    Accepted Solution

    figured it out:

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

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now