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();
}
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 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.