2
votes

I have an application level Excel VSTO addin with an xml ribbon. Currently, when opening two or more workbooks in the same excel instance, the same ribbon instance is shared across all the workbooks.

This is a problem since there are certain variables in the Ribbon class whose values should be different for each workbook. Since only one instance of that Ribbon class is created, so when a particular operation on a workbook sheet causes a variable value to change that value is changed for the other opened workbooks also. However, that shouldn't happen.

Is there any way that each time a new workbook is opened a new Ribbon instance can be created?

1

1 Answers

1
votes

No, it's not possible to create document- or window-specific instances of the Ribbon within a single instance of the Excel application.

Your code would need to track events such as Workbook.Open and WorkbookActivate to determine when a different workbook is the one the user is working with. Use Invalidate and InvalidateControl methods of the Ribbon UI to trigger callbacks to change the Ribbon control states as necessary to reflect the settings for the workbook.