PDA

View Full Version : Keeping modeless userform on top



cheng
10-24-2015, 12:35 AM
Hi,
I have a macro that opens an external workbook and does some processing to it. I am using a modeless userform to notify the user on the progress of the macro, and also to enable the user aborting the macro.
My problem is that the userform is constantly being sent to the back (i.e. disappears) and pops up again during the execution if the database is very large and the macro needs to run for a long time. Also, the cancel button that I put on the userform is not very effective because it takes a long time to respond, if at all (of course it cannot work if the userform is hiding behind the workbook...).
I tried using DoEvents as was suggested in other threads on this topic, but it doesn't seem to be very reliable.
If necessary, I am willing to use the status bar instead of the userform to indicate progress, but what can I do to make the cancel button work effectively?

Thanks,
Chen

Jan Karel Pieterse
10-24-2015, 03:46 AM
Excel 2013 and later have a new way of working with workbook windows, which means a userform is parented to te workbook tha called it. Any other workbook you activate will show up on top of the userform. I devised a way to overcome this here: http://www.jkp-ads.com/articles/keepuserformontop.asp

cheng
10-24-2015, 04:58 AM
Thanks! I'll give it a try