0
votes

So, I have created a ribbon in an Excel VSTO addin. This ribbon has labels that I would like to update based on values that are present within workbook cells.

The issue is that the label values are persisting across workbooks - they are not workbook specific.

I have a code that refreshes the labels, and could set it to refresh on change of activate workbook.

The issue with this is where the user has two workbooks open side by side - they will see the same label on both ribbons even though the workbooks should be showing separate values.

Does anyone have any suggestions to solve this? Currently I am setting the label values as so

Globals.Ribbons.CustomRibbon.lblClientCode.Label =

1

1 Answers

0
votes

Regardless of how many workbooks you have opened, there is always only one ribbon object to all of them.

Therefore you should handle the Application.WorkbookActivate event and update your ribbon label text according to the values in the respective workbook.