+ Reply to Thread
Results 1 to 7 of 7

Removing or disabling the X button in Userforms

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Removing or disabling the X button in Userforms

    Hi there

    Does anyone have a code for removing the X button on a userform?

    Cheers
    Dan

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Removing or disabling the X button in Userforms

    Hi DanzaNZ,

    Though I haven't got the exact link, I do know the following originated from OzGrid:

    Please Login or Register  to view this content.
    Just include the above code in the relevant form.

    Make sure you also have code to close the form and the desired point as the user will no longer be manually able to do it.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Removing or disabling the X button in Userforms

    This doesn't remove the X button, but it does prevent it from closing the userform. It's still there but does nothing.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Removing or disabling the X button in Userforms

    Quote Originally Posted by AlphaFrog View Post
    This doesn't remove the X button, but it does prevent it from closing the userform. It's still there but does nothing.

    Please Login or Register  to view this content.
    Thanks AlphaFrog

    Does this code still enable a command button to be coded to close the form?
    My command button is set to close the entire workbook.

    Cheers
    Dan

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Removing or disabling the X button in Userforms

    Quote Originally Posted by DanzaNZ View Post
    Thanks AlphaFrog

    Does this code still enable a command button to be coded to close the form?
    My command button is set to close the entire workbook.

    Cheers
    Dan
    Yes.

    The code only disables the X button. You could still close the userform by any other method.

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Removing or disabling the X button in Userforms

    Quote Originally Posted by AlphaFrog View Post
    Yes.

    The code only disables the X button. You could still close the userform by any other method.
    Great!

    Solved, thank you AlphaFrog!

    Cheers
    Dan

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Removing or disabling the X button in Userforms

    FYI - For those who are interested in actually removing the Close X from a window or UserForm, here is the code.

    BE CAREFUL WITH THIS CODE

    It removes the Close X from the Active Window. To use with a UserForm add a call to the macro RemoveCloseX in the UserForm_Activate() event module

    Remove the Close X on a UserForm
    Please Login or Register  to view this content.
    Windows 7 and Later
    This code is compatabile with Windows 7 and later. Add a new VBA module to your workbook and paste the code below into it.
    Please Login or Register  to view this content.
    Windows 95 through XP
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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. Replies: 0
    Last Post: 04-21-2011, 09:20 AM
  2. ClearContents and Clear not removing previous copied terms (from userforms)
    By eurydice88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-02-2010, 11:41 AM
  3. Creating and removing Userforms at runtime
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2010, 12:33 PM
  4. Removing Userforms
    By SDA in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-15-2008, 06:51 AM
  5. Userforms: Disabling - Enabling the X
    By Lauri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2006, 02:10 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