Keep UserForm on Top (Office365, 64-bit)

chester1993

New Member
Joined
Jan 26, 2016
Messages
40
Hello All,

As the title says, I have around 7 UserForms and I want them to be always on top of ALL windows once opened.
Currently, I had set the ShowModal to False on the UserForm properties. My issue is when I minimize Excel, it also minimize the UserForm.
Details of the file:
• Office 365
• 64-bit

I found a thread here (Userform.... Always on top and Keep a UserForm on Top of All Other Windows), but these thread seems to be outdated already. If I am reading it right, they are using a lower version of Excel VBA and codes are for 32-bit.

I wonder if someone can help me with an updated code. These are "complex" codes and for someone who is only starting with VBA, this is kind of a big stretch.
I apologize in advance if I had to create a new thread for this as I was afraid some people might not be able to read my request to update those threads.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
The code in that second link is clearly stated to be for 64bit. Did you try it?
 
Upvote 0
@RoryA I did tried the code. One thing confusing me is, though the code works fine, when I minimize Excel, it also minimize the UserForm. Is there not a way to be like that? Also, I wanna add a Minimize and Maximize option on that UserForm. I think the 64-bit code only works on keeping the UserForm on top.

EDIT: I tried the code on the 1st link that says would add minimize and maximize buttons. But I am having a "variable not defined" error pointing on WS_MINIMIZEBOX
 
Last edited:
Upvote 0
Then you didn't copy all of the code as that constant is declared in the code posted. ;)
 
Upvote 0
That's what puzzled me. I copy everything as it is. I didn't change a single thing in the codes. Lol.

Again, the issue I am facing now is: although, the userform is on top, when Excel is minimized, the userform goes with it. And, I can see on the codes that there should be a maximize and a minimize button, but I dont see it on my userform. Lol.

I don't know. Is there something I need to change on those codes? Is there a plug-in I need to activate? I am doing this on a computer in the office, as my form will be use within the office, was there something blocked on my excel that I need to check why its not working? Haha.
 
Upvote 0
It's about the 10th line of that code:

Code:
Public Const WS_MINIMIZEBOX = &H20000
 
Upvote 0
I'm saying that that constant is declared on that line, so if you're getting that error, you could not have copied all the code.
 
Upvote 0
I managed to made this work. Hmm. One question is, what if I want a toggle button to activate or deactivate always on top?
How would I go about that @RoryA ? I am not sure what to "call" in order for the toggle to work.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top