Re: [FAQ's: OD] How do I set a UserForm to be the TopMost form throughout Windows?
Originally Posted by RobDog888
If you make a small modification in the UserForm_Initialize event you can make your UserForm act like a normal Windows Form like it was independant from the main Excel window.
Using the above code, add one more line of code as shown below...
Code:
Private Sub UserForm_Initialize()
mlHwnd = FindWindow("ThunderDFrame", "UserForm1") 'Change to match your userforms caption
Do While mlHwnd = 0
mlHwnd = FindWindow("ThunderDFrame", "UserForm1") 'Change to match your userforms caption
DoEvents
Loop
'Set topmost
SetWindowPos mlHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
CommandButton1.Caption = "Not Topmost"
'Minimize Excel's main window if you want to present the UserForm as a standard Form not "associated" with Excel.
Application.WindowState = xlMinimized
End Sub
I get reprimanded if I use DoEvents in any code !
Poppa.
Along with the sunshine there has to be a little rain sometime.