I have successfully implemented the Microsoft sample Walkthrough: Synchronizing a Custom Taskbar Using the Ribbon Button, which is located here: http://msdn.microsoft.com/en-us/library/bb608590.aspx
Initially, I ran into a problem when the taskbar did not appear, which turned out to be the result of some conflict between my add-in and Microsoft Analysis Toolkit. As soon as I turned off the Analysis Toolpack, the custom taskbar started showing and hiding as expected.
Then I wrote code to change the cells in the selected range when the user clicks a button. Everything seemed to work just fine until I opened another book! Each book window has its own ribbon for adding, but when I clicked the switch button to open / close the taskbar, it will open / close the taskbar for the first window created. This is regardless of the window in which I press the toggle button.
The code creates an instance of the CustomTaskPane object in ThisAddIn_Startup (as in the code example). The only thing I added is the button action in UserControl:
using xl = Microsoft.Office.Interop.Excel; namespace SynchronizeTaskPaneAndRibbon { public partial class TaskPaneControl : UserControl { public TaskPaneControl() { InitializeComponent(); } private void actionButton1_Click(object sender, EventArgs e) { xl.Range selection_rng = Globals.ThisAddIn.Application.Selection; foreach (xl.Range cell in selection_rng.Cells) { if (cell.Value is string) { string v = cell.Value; cell.Value = v + "*"; } } } } }
The rest of the code is the same as in the example.
Is there a way to change the example so that it works to open multiple books? I want the same Add-In to appear in every window of the book, with the same ribbon and with the same user panel. And, of course, in order for any actions with the ribbon (for example, pressing a button) to go to the user task panel, which appears in the same window.
Garyp source share