excel-vba Common Mistakes Single Document Interface Versus Multiple Document Interfaces


Example

Be aware that Microsoft Excel 2013 (and higher) uses Single Document Interface (SDI) and that Excel 2010 (And below) uses Multiple Document Interfaces (MDI).

This implies that for Excel 2013 (SDI), each workbook in a single instance of Excel contains its own ribbon UI:

enter image description here

Conversely for Excel 2010, each workbook in a single instance of Excel utilized a common ribbon UI (MDI): enter image description here

This raise some important issues if you want to migrate a VBA code (2010 <->2013) that interact with the Ribbon.

A procedure has to be created to update ribbon UI controls in the same state across all workbooks for Excel 2013 and Higher.

Note that :

  1. All Excel application-level window methods, events, and properties remain unaffected. (Application.ActiveWindow, Application.Windows ... )
  2. In Excel 2013 and higher (SDI) all of the workbook-level window methods, events, and properties now operate on the top level window. It is possible to retrieve the handle of this top level window with Application.Hwnd

To get more details, see the source of this example: MSDN.

This also causes some trouble with modeless userforms. See Here for a solution.