How to determine whether to use an Excel Workbook project or Excel Addin project

Posted on 2011-05-03
Last Modified: 2013-11-10
Using VS 2010 and C#, I need to determine whether to use an Excel Workbook project or Excel Addin project ?

I understand we have three main levels:

  App-level, Doc-level, and Office UI customization

In my case I would like to add a new group to Excel representing my company's name, then roll that out to certain users.
I would like to create some Excel workbooks based on what menu option the users chooses. i.e. I've accomplished some of this already via Excel VBA, however I'd like to convert some of these VBA Report I've created into a C# project, then hook that into the Excel IDE.

The problem I have is understanding how to use all the Excel class in a Addin project.

For example, using as a guide I noticed these commands below are not recognized in my Addin project; they are only recognized in the Workbook project. I imagine I'm missing certain class references:

Microsoft.Office.Tools.Excel.NamedRange textInCell;
textInCell = this.Controls.AddNamedRange(this.get_Range("A1", missing), "cellText");

textInCell.Value2 = "Hello world!";

Perhaps someone could lead me in the right direction.

Thanks ahead of time.


Question by:jgroetch
    LVL 96

    Expert Comment

    by:Bob Learned
    I guess us Bobs got to stick together *BIG GRIN*

    I don't specifically know the answer to your question, but it has fallen through the cracks.  I have been in this business long enough to know that just because I don't know the answer doesn't mean that we can't come up with one together.

    I would need to set up a small test application for each case, but my initial impressions are that you would want a Workbook project, and not an add-in (after 1 minute of reading)...

    Bob "The Learned One"
    LVL 30

    Accepted Solution

    An applicaiton level addin is probably what you want here. However, may you provide a bit more detail on the actaul error message you are receiving on the lines in question. You can perhaps post a screenshot of the Error List window.
    LVL 1

    Author Comment

    Hello gents and thanks for the response.
    I realize my question is not super clear. It's more a question of direction rather than specific bugs; however, here's a specific example of something that I'm seeing.

    In the c# code below I've created a test 2010 Workbook Project in VS2010.
    I've tried to use the same type of "NamedRange" class references in a Addin Project (i.e. I want to customize the UI Ribbon) however I get this error:

          'MyExcelRibbon3.MyRibbon' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'MyExcelRibbon3.MyRibbon' could be found (are you missing a using directive or an assembly reference?)      C:\Users\..\Documents\Visual Studio 2010\Projects\MyExcelRibbon3\MyExcelRibbon3\MyRibbon.cs      70      35      MyExcelRibbon3

    I suppose in the end certain project types do not expose the same class references or assemblies that others do, so I need to be clear on what I'm doing...
    Again, how do I determine if I'm creating a "Application level project" or "Document level project" ?

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml.Linq;
    using Microsoft.Office.Tools.Excel;
    using Microsoft.VisualStudio.Tools.Applications.Runtime;
    using Excel = Microsoft.Office.Interop.Excel;
    using Office = Microsoft.Office.Core;
    namespace FirstWorkbookCustomization
        public partial class Sheet1
            private void Sheet1_Startup(object sender, System.EventArgs e)
                NamedRange nr = this.Controls.AddNamedRange(this.Range["A2", missing], "NamedRange1");
                nr.Value2 = "This text was adding by the c# code !!!";            
            private void Sheet1_Shutdown(object sender, System.EventArgs e)
            #region VSTO Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
                this.Startup += new System.EventHandler(Sheet1_Startup);
                this.Shutdown += new System.EventHandler(Sheet1_Shutdown);

    Open in new window

    LVL 1

    Author Closing Comment

    application-level Addin is the proper Project type when creating a custom tab that needs to be implemented to a user desktop.
    LVL 1

    Author Comment

    I ended up also finding someuseful tips over at ms forums. In the end, I have determined that the vs 2010 project I need is an Excel Addin project.
    At that point I can go ahead with the Visual Ribbon Designer tool and create my custom tab.
    I can also create a user control and then add a Custom Task Pane to my control. i.e. User Task Panes are available in Workbook project types, but NOT in Excel Addin project types. this means I need to create a "Custom" Task Pane ( ref link ).

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
    This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

    733 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

    25 Experts available now in Live!

    Get 1:1 Help Now