+ Reply to Thread
Results 1 to 10 of 10

Userform always on top

  1. #1
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Userform always on top

    HI Guys,

    I want my userform to always stay on top. At the moment it does until a new excel book opens up effectively hiding it.

    My code in the userform is:

    Please Login or Register  to view this content.
    This is the code I run in my subs to call the form
    Please Login or Register  to view this content.
    If I run the userform code by itself, it stays on top when I click around....

    any ideas?

    Thanks

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform always on top

    I found this a while back and saved it... can't take credit for it.

    Please Login or Register  to view this content.
    Now I look carefully you are using a version of this already, so it may not help...
    Last edited by Arkadi; 05-12-2017 at 09:25 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform always on top

    Guess you've upgraded to 2013 or 2016 rather than the 2010 mentioned in your profile...?

    EDIT: The post above (and your original code) has the disadvantage that the userform will be shown over other messages, like error messages... and, if big enough, will completely hide them.
    Last edited by cytop; 05-12-2017 at 09:35 AM.

  4. #4
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Userform always on top

    I have indeed Cytop Eagle eyed! Changed it
    I understand it may cover errors etc however the only error that could occur during the time of it being open/closed would be a filepath call issue really. So I'm good with that

    Arkadi - I shall give it a go - thanks for trying either way!

  5. #5
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Userform always on top

    Arkadi - Sadly when opening a new excel book it still doesn't show on top
    Might have to be a reactivate the userform job!

    Thanks anyway

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform always on top

    Ok here's another try... (testing on my end works with this method)

    At the top of your userform code:

    Please Login or Register  to view this content.
    And add this to the userform_initialize code (or put all the code together in a module, put the below code in a sub, and call it from the userform initialize):

    Please Login or Register  to view this content.
    Last edited by Arkadi; 05-12-2017 at 10:51 AM.

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform always on top

    See this recent thread...

    @Arkadi: If your profile is correct (XL2010), it will work - see post #2 in the link for an explanation.
    Last edited by cytop; 05-12-2017 at 10:51 AM.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform always on top

    @ cytop, thanks, didn't realize this won't work in later versions. My first code post (#2) would not keep the userform on top of another instance of excel, while my last post (#6) DID stay above all other applications... I was hoping maybe that latest post would work in later versions too... but perhaps not.

    Just tested in a 2013 version of office, and my post #6 does seem to keep the userform above any other application windows without problem.
    Last edited by Arkadi; 05-12-2017 at 11:01 AM.

  9. #9
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform always on top

    does seem to keep the userform above any other application
    Yes, it will as you're setting it TOPMOST (above all other Windows) - but that's introduces other issues especially the fact an error message or a notification from another application, can be hidden - as the OP mentioned, it's probably not a problem here, but I would pick that up in any code review and send it back for re-work. That's just me, though.

    Apols in a way - I didn't mean to imply it would not work in other versions - my error by omission, I didn't make myself clear.
    Last edited by cytop; 05-12-2017 at 11:17 AM.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform always on top

    No worries at all cytop , I appreciate the feedback, and see no need at all for you to apologize! .... I do understand there are drawbacks, perhaps I too ought to have put a warning along with the code. I took the OP's requirement to be what that code does, but it is important to understand the consequences

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Save data from UserForm into Sheet (how to resolve runtime errors in UserForm tutorial)
    By eighty6 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2015, 07:41 PM
  2. Userform Combobox - select from list, store this as default each time userform loads
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2014, 07:48 AM
  3. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  4. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  5. [SOLVED] Changed userform combobox to listbox, unable to get userform to retrieve datasheet values
    By dragonabsurdum in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2013, 01:38 PM
  6. [SOLVED] Open a userform from a userform, but preserve the info in the original userform
    By jfoerch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2013, 02:38 PM
  7. userform is large.....how to use scrollbar of userform to show all of the userform
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2010, 04:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1