Keep UserForm on Top (Office365, 64-bit)

chester1993

New Member
Joined
Jan 26, 2016
Messages
38
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.
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
The code in that second link is clearly stated to be for 64bit. Did you try it?
 

chester1993

New Member
Joined
Jan 26, 2016
Messages
38
@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:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Then you didn't copy all of the code as that constant is declared in the code posted. ;)
 

chester1993

New Member
Joined
Jan 26, 2016
Messages
38

ADVERTISEMENT

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.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
It's about the 10th line of that code:

Code:
Public Const WS_MINIMIZEBOX = &H20000
 

chester1993

New Member
Joined
Jan 26, 2016
Messages
38

ADVERTISEMENT

It's about the 10th line of that code:

Code:
Public Const WS_MINIMIZEBOX = &H20000
Im not sure how to respond to this. I mean, what about the 10th line? What am I missing? I am sorry. I am noob at this. Lol
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
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.
 

chester1993

New Member
Joined
Jan 26, 2016
Messages
38
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

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
Top