Excel 2013 VSTO Ribbon & Edit Controls

2019-03-29 20:20发布

问题:

The quick overview is I have an Excel AddIn targeting Excel 2013. The AddIn has a custom RibbonUI that contains a couple of read-only EditBoxes that contain workbook specific values. The same AddIn works fine in Excel 2007 & 2010, with the MDI interface, but with 2013 and its SDI interface.

With a simple VSTO AddIn, I've added a simple RibbonUI with an EditBox. For testing purposes, I'm just trying to get the EditBox to reflect the Workbook.Fullname of the window in which it appears. Far as I've been able to find, the RibbonUI is a singleton and there's no apparent way to control the values of any edit controls on a per workbook/window basis. If I have 2 Excel Workbooks open and switch back and forth (updating the value on the ActiveWorkbookChanged property of the Excel.Application), both workbooks always reflect the most recent value. Worse yet, only one event fires, but both windows are updated.

The crux of the problem is that I cannot find a way to control in a per window/workbook manner the value of an edit control. I found Programming for the Single Document Interface in Excel 2013, except it doesn't mention, or provide any references on how to do it, just that you need to.

I'll try and update later with some examples, but I'm wondering if anyone has solved this problem with SDI under Excel 2013? It is obvious looking at built-in Ribbon controls in 2013 that is is possible to do this (for instance, Font settings), but documentation seems exceptionally sparse on how to accomplish something similar from a user AddIn.