Excel 2013, SDI and modeless userforms

Hi Everyone,

With Excel 2013 we also got new document windowing in Excel; Microsoft decided to make Excel behave the same as Word:

from MDI:

Excel 2010 MDI interface showing two workbooks
The Excel 2010 MDI interface

to SDI:

Excel 2013 SDI interface showing two workbooks
The new SDI interface of Excel 2013

This causes havoc when one shows a modeless userform which should stay on top of all Excel windows:

Excel 2013 SDI can cause a userform to disappear
Excel 2013 SDI can cause a userform to disappear

I’ve devised a way to prevent this problem and written an article about how this was done.



Jan Karel Pieterse





4 thoughts on “Excel 2013, SDI and modeless userforms

  1. Tried many of the tricks to no avail.

    In my XLAM a modeless UserForm is created and shown/hidden via a ToolBar/Ribbon Element. This works fine in XL2000-XL2010.

    When in XL2013 I have multiple Excel windows open (different dox but also different windows of the same doc) I try via the WindowActivate event to force the UserForm on top of all others, using different Win32API’s (e.g. “SetWindowPos”, “BringWindowToTop”, …).

    The effect is that when I click another Excel window which is not the top most one, the WindowActivate event gets triggered in the XLAM, and the UserForm is correctly brought “on top” but then also the Excel window from which I showed the UserForm initially is brought up as well (while respecting their Z-Order).

    In practice, the “on top” action pushes the Excel window I clicked back in the Z-Order stack, behind the UserForm (what I want) but also behind the Excel window linked to the UserForm.

    I tried hiding and showing of the UserForm in between, but it did not work.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.