[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


load analysis toolpak from c# starts up excel

Posted on 2011-10-13
Medium Priority
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
  • 2

Author Comment

ID: 36965283
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

solarissf earned 0 total points
ID: 36965941
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


Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

872 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