locked
Creating a custom Tab using the Ribbon Designer RRS feed

  • Question

  • I have begun creating a custom tab in Excel for my company. I got started by using this Walkthrough: http://msdn.microsoft.com/en-us/library/bb386104.aspx , and so far I can see the new tab after running my Visual Studio project (C# is my choice of language). i.e. The company tab is available and I can also click on the Action Panes that I created, etc.

    However, I am trouble with "rolling out" the Excel addin to my desktop. Funny thing is that I CAN in fact see that my Excel project in Add/Remove programs via control panel, but can't see my new Excel tab when I launch Excel.

    I have "Published" the setup code to my local drive (Visual Studio 2010\Projects\MyExcelRibbon3\MyExcelRibbon3\publish\) and was able to run the SETUP.EXE file. It says it's all installed but I cannot see the new company group in Excel each time I launch Excel in Win 7.

    One of my main questions is:

    1) What is the correct PROJECT TYPE I need to create in order to accomplish this rollout to each user desktop. In other words, do I create an "Excel Workbook" project as I did here in the walkthrough example above, or do I create an "Excel Addin" project; or does it really matter either way ?

    Any ideas on this ? My apologies if I'm not so clear. I am still trying to learn the best approach to customizing Excel , etc.

    Thanks,

    Bob

     

    Thursday, May 5, 2011 6:53 PM

Answers

  • Hello,

    The example presented in that walkthrough adds the custom tab to a specific Excel workbook. This is fine if you plan to have users open that specific workbook on their desktops. If you want the tab to appear in Excel for all workbooks, you would want to create an Excel add-in project and then add a Ribbon (Visual Designer) item to the add-in project.


    Norm Estabrook
    • Marked as answer by Bob Mazzo Thursday, May 5, 2011 8:54 PM
    Thursday, May 5, 2011 7:11 PM
    Answerer
  • Hi Bob,

    Yes Actions panes are only supported in document-level projects (such as an Excel Workbook or Word Document projects). The following article outlines supported UI customization templates available for each project type - Office UI Customization.

    If you want to create a UI pane either to the side, top, or bottom of the Excel window, your best bet is probably to create a Custom Task Pane.  You can read about them here - Custom Task Panes Overview. There is also a topic that discusses how to synchronize data in a custom task pane with a custom Ribbon within an Excel Add-in project which should be right up your alley here - Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button.


    Norm Estabrook
    Thursday, May 5, 2011 8:06 PM
    Answerer
  • I actually found the solution here : http://msdn.microsoft.com/en-us/library/bb608590.aspx (Synchronizing a task pane with ribbon button)

    I added the visible_changed event in ThisAddIn_Startup:

      taskPaneValue.VisibleChanged +=
    new EventHandler(taskPaneValue_VisibleChanged);

    and also added a PUBLIC proprety at the top of ThisAddin, then the toggleButton1_Click() in the Ribbon code-behind:

     

    public Microsoft.Office.Tools.CustomTaskPane TaskPane
    {
    get
    {
    return taskPaneValue;
    }

    • Marked as answer by Bob Mazzo Monday, May 9, 2011 8:22 PM
    Monday, May 9, 2011 8:22 PM

All replies

  • Hello,

    The example presented in that walkthrough adds the custom tab to a specific Excel workbook. This is fine if you plan to have users open that specific workbook on their desktops. If you want the tab to appear in Excel for all workbooks, you would want to create an Excel add-in project and then add a Ribbon (Visual Designer) item to the add-in project.


    Norm Estabrook
    • Marked as answer by Bob Mazzo Thursday, May 5, 2011 8:54 PM
    Thursday, May 5, 2011 7:11 PM
    Answerer
  • Hi Norm,

    I actually just realized this as per this walkthrough: http://msdn.microsoft.com/en-us/library/cc668205.aspx, meaning that an Addin project is the correct PROJECT TYPE.

    HOWEVER, I am super confused as to the differences between Addin projects versus Workbook projects. I mean, certain code examples I find online DO NOT work depending on the project type (i.e. certain assemblies or classes are not exposed, etc.).

    For example, with an Addin project I CAN add a Ribbon (Visual Designer) component via Project/Add-New-Item, but I CANNOT add an ActionsPaneControl to my project.

    I am basically looking to create a custom Excel tab group, then add menu items to add user functionality. In turn those functions will create an Excel workbook to display lots of financial data.

    How do I accomplish all of this, and how do I get my ActionsPane Control as wel..

     

    thank you in advance !

    Bob

    Thursday, May 5, 2011 7:44 PM
  • Hi Bob,

    Yes Actions panes are only supported in document-level projects (such as an Excel Workbook or Word Document projects). The following article outlines supported UI customization templates available for each project type - Office UI Customization.

    If you want to create a UI pane either to the side, top, or bottom of the Excel window, your best bet is probably to create a Custom Task Pane.  You can read about them here - Custom Task Panes Overview. There is also a topic that discusses how to synchronize data in a custom task pane with a custom Ribbon within an Excel Add-in project which should be right up your alley here - Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button.


    Norm Estabrook
    Thursday, May 5, 2011 8:06 PM
    Answerer
  • Okay Norm, it's becoming clearer to me today. Thank you for those links. I've seen them before but the influx of information was causing me a brain overload, and I couldn't put the pieces together until now.

    Okay so once I've created my app-level addin, as well as my custom task panes, all my other Excel Workbook manipulation will still be possible correct ? i.e. Excel automation and workbook creation, etc.

    What I'm trying to do ultimately is replace some of the previous Excel VBA code that was very workbook-specific, and instead have it in visual studio with c# - then of course make it available via a custom tab and roll out that Addin to my users. All the behind-the-scenes stuff is really just sending a request to an app server and receiving back one or more xml files. At that point it's up to me to parse the xml and format it nicely into Excel (i.e. one solution for those front-end trader types and excel lovers).

    Does my high-level plan of attack make sense to you ? Any additional advice or gotcha's you can throw my way ? :-)

     

    Thank you again !!!

    Bob

     

    Thursday, May 5, 2011 8:53 PM
  • Hi Bob,

    Yes your plan makes perfect sense. All of the same workbook automation tasks that you previously performed in VBA, you can perform by using the Excel object model from within your add-in. You have probably already seem some of the example topics below:

    Working with Workbooks

    Working with Worksheets

    Working with Ranges

    Working with Cells

    Most of these code snippets show examples that work with Excel Add-in projects.

    If you get stuck on how to accomplish something that seems to you like it should be dead simple, just record a macro to see what objects were used to perform the task. You can look at the code to see what objects the macro generator used. Some time ago I wrote a blog about that approach here - I just want to format a cell in my Excel Worksheet (Norm Estabrook). 


    Norm Estabrook
    Thursday, May 5, 2011 10:09 PM
    Answerer
  • I'm not sure if I should open up a new question, but I'll give this a try anyhow:

     

    As per this walk through -  http://msdn.microsoft.com/en-us/library/aa942846.aspx - I can add a Custom Task Pane to my Excel Addin project.

    All is well in this section of code, and I can certainly see the custom pane in Excel when I launch the project :

    public partial class ThisAddIn

        {
            // Adding a Custom Task Pane to an application - see http://msdn.microsoft.com/en-us/library/aa942846.aspx
            private MyUserControl myUserControl1;
            private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;

            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                myUserControl1 = new MyUserControl();
                myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "Razor Settings");
                myCustomTaskPane.Visible = true;
            }
        }
    }

     

    HOWEVER, how do I now expose this custom control to my entire project so I can show/hide my Custom Pane at will ? Do I use the above code in every single partial class I create ?

    Example: I've created a custom Tab using the Visual Ribbon Designer. I've also added "Groups" to my custom tab, and now I'm creating several buttons. Once I click on certain buttons I want to DISPLAY the custom take pane, however not sure get access to "myUserControl1" that I created in my ThisAddIn class above.

    Thank you in advance.

    Bob

     

    Monday, May 9, 2011 5:19 PM
  • I actually found the solution here : http://msdn.microsoft.com/en-us/library/bb608590.aspx (Synchronizing a task pane with ribbon button)

    I added the visible_changed event in ThisAddIn_Startup:

      taskPaneValue.VisibleChanged +=
    new EventHandler(taskPaneValue_VisibleChanged);

    and also added a PUBLIC proprety at the top of ThisAddin, then the toggleButton1_Click() in the Ribbon code-behind:

     

    public Microsoft.Office.Tools.CustomTaskPane TaskPane
    {
    get
    {
    return taskPaneValue;
    }

    • Marked as answer by Bob Mazzo Monday, May 9, 2011 8:22 PM
    Monday, May 9, 2011 8:22 PM