none
Adding UserControl/Action Pane in MS-Excel plugin developed in VB.NET RRS feed

  • Question

  • Hey i have added a UserControl in my Excel plugin(2010).Project..Now i want to add it to my workbook and wanted to show whenever Ribbon Loads....

    I have seen some examples  also that are saying that and coded like below:

    public partial class RibbonControls : RibbonBase
        {
            ActionsPaneControl1 AP1 = new ActionsPaneControl1();

            public RibbonControls()
                : base(Globals.Factory.GetRibbonFactory())
            {
                InitializeComponent();
            }

            // Load event fires when the Ribbon loads
            // Actions Pane is added to the project but remains hidden until the user chooses to show it
            private void RibbonControls_Load(object sender, RibbonUIEventArgs e)
            {
                Globals.ThisWorkbook.ActionsPane.Controls.Add(AP1);
                AP1.Hide();
                Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = false;
            }
    }

    this is the part of the downloaded sample but it is working fine

    I have written my own code in this way;

    Imports Microsoft.Office.Tools

    Public Class ThisAddIn

    Dim objExport As New EXport()
        Private Sub ThisAddIn_Startup() Handles Me.Startup
            Application.CellDragAndDrop = True
            Me.Application.ThisWorkbook.ActionsPane.Controls.Add(objExport)
      
        End Sub

        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

        End Sub

    End Class

    objExport is the instance of the user control but it gives me com exception error

    Please help me what to do and how , The examples from google are also saying that i should write the code in startup event of the Workbook but how can i write this ...

    I mean Workbooks are generated as the part of the application..

    I mean how can i add and open the Usercontrol in EXCEL plugin 2010

    Urgent

    please help

    Thursday, December 8, 2011 6:03 PM

Answers

  • Use a Custom Task Pane instead of an Actions Pane. It's basically the same thing, except an Actions Pane is linked to one, specific VSTO document and a Custom Task Pane is meant to be used with an add-in.

    Read the information in the link I gave you, plus the articles to which it links.


    Cindy Meister, VSTO/Word MVP
    Saturday, December 10, 2011 9:19 AM
    Moderator

All replies

  • Hi Archana

    You're mixing up two different types of VSTO customization:

    Public Class ThisAddIn

    Dim objExport As New EXport()
        Private Sub ThisAddIn_Startup() Handles Me.Startup
            Application.CellDragAndDrop = True
            Me.Application.ThisWorkbook.ActionsPane.Controls.Add(objExport)
      
        End Sub

    You have a VSTO Add-in project, but the code in it you use for a task pane is specific to a Workbook (single file) customization.

    You need to use CustomTaskPane with an Add-in. The MSDN documentation starts with this article:
    http://msdn.microsoft.com/en-us/library/aa942864.aspx


    Cindy Meister, VSTO/Word MVP
    Friday, December 9, 2011 7:25 AM
    Moderator
  • hey Cindy..

    Let me explian you what i am trying to dooo...May be i am wrong then please correct me

    I have an EXport button in my own Ribbon...what i want  to do is ,,i want to open a usercontrol that will contain (Textbox and a label and some other fields in that control) in it just like windows application that opens the windows in another window.

    i  have aded the user control but following these steps to add it into action pane as i have seen some exmaples..

    But i think i am wrong..

    then please tell me how can i show the usercontrol on the click event of button in my RIBBON.

    Friday, December 9, 2011 8:00 AM
  • Use a Custom Task Pane instead of an Actions Pane. It's basically the same thing, except an Actions Pane is linked to one, specific VSTO document and a Custom Task Pane is meant to be used with an add-in.

    Read the information in the link I gave you, plus the articles to which it links.


    Cindy Meister, VSTO/Word MVP
    Saturday, December 10, 2011 9:19 AM
    Moderator