I have created a VS Addin Project where I have written code to add a custom menu with some menu items in C#. By this I got a VSTO deployment file. Now I open a random excel file and add this addin or vsto manually by Excel Options-> Addins->Manage (Com Addins) -> Go and Added the addin. My isuue is that the addin gets added in all files alongwith the file in which I added. I want that the user view this addin menu for the file for which s/he added manually. Our approach is free to ask user to go thru some special steps to follow or I can write C# code also for achieving this. Also we cannot do this by identifying the file name as the name and location of file may change. Please suggest any workaround as I am totally stuck on this issue.
1
votes
1 Answers
0
votes
why don't you create a toggle button to show/add and hide/remove your custom task pane.
follow the instruction at:
http://msdn.microsoft.com/en-us/library/aa942846.aspx
msdn.microsoft.com/en-US/office/hh128771
create a excel addin using visual studio.
add a user control, a ribbon (visual) using right click -> add new
user control will be your takspane.
add a toggle button in the ribbon.
then, in the ThisAddIn.cs
add following lines:
private UserControl1 myUserControl1;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
myUserControl1 = new UserControl1();
myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "My Task Pane");
}
public void toggle(bool b)
{
myCustomTaskPane.Visible = b;
}
after that, in the Ribbon1.cs
add the following code :
private void toggleButton1_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.toggle(toggleButton1.Checked);
}
Hope this will work for you.