Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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
VB
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 start-up 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.
Posted
Updated 8-Dec-11 23:19pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900