+ Reply to Thread
Results 1 to 2 of 2

Disable Excel Close button (X) on Menu

Hybrid View

  1. #1
    Registered User
    Join Date
    10-15-2007
    Posts
    6

    Disable Excel Close button (X) on Menu

    Hello,
    In our Program we have a Disconnect button but most of the users are bypassing the Disconnect button and click on the Excel Close button. Could some one suggest me how to Disable the Excel Close button (X) on the Menu and Enable it when they click on the Disconnect.

    Please suggest on how I should do this.. Thank you.
    -Regards,
    Venky

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon venkia

    Use some code such as this to stop users closing by clicking on the X (or even going to File > Close / Exit) :

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Cancel = True
    MsgBox "Cannot close this way"
    End Sub
    This needs to go in the ThisWorkbook object within the VBE.

    To stop this from working use a piece of code like this :
    Application.EnableEvents = False
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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