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:
to SDI:
This causes havoc when one shows a modeless userform which should stay on top of all Excel windows:
I’ve devised a way to prevent this problem and written an article about how this was done.
Enjoy!
Regards,
Jan Karel Pieterse
Here’s another way without class modules and OnTime loop but using three Application events and three API calls behind userform object.
http://cpap.com.br/cd.asp?F=ModelessformOnTop002.zip
Hi Orlando,
I like that approach, thanks!
Jan Karel Pieterse,
> I like that approach, thanks!
Good! Thanks for testing and feedback.
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.
Dutch