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

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

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 http://msdn.microsoft.com/en-us/library/a0ytdsk6.aspx 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.

Bob

0
jgroetch
Asked:
jgroetch
  • 3
1 Solution
 
Bob LearnedCommented:
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"
0
 
MlandaTCommented:
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.
0
 
jgroetchAuthor Commented:
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" ?


thanks,
Bob
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);
        }

        #endregion

    }
}

Open in new window

0
 
jgroetchAuthor Commented:
application-level Addin is the proper Project type when creating a custom tab that needs to be implemented to a user desktop.
0
 
jgroetchAuthor Commented:
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 http://msdn.microsoft.com/en-us/library/aa942846.aspx ).
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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