+ Reply to Thread
Results 1 to 3 of 3

Close button Excel 2003 greyed out can't be undone

Hybrid View

  1. #1
    Registered User
    Join Date
    10-24-2008
    Location
    netherlands
    Posts
    35

    Close button Excel 2003 greyed out can't be undone

    Using Excel 2003, with below code it should be possible to turn off and on the close button of the Excel application.
    Turning off (xapplicatieuit) works just fine; the button gets greyed out, but if I try to turn it on (xapplicatieaan) nothing happens.
    Is this typical 2003 or am I doing something wrong?
    Option Explicit
    
    Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal uIDEnableItem As Long, ByVal uEnable As Long) As Long
    'Used to find the Outlook icon in the system tray. If present then Outlook is running
    Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Const MF_BYCOMMAND = &H0&
    Public Const MF_BYPOSITION = &H400&
    Public Const SC_ARRANGE = &HF110
    Public Const SC_CLOSE = &HF060
    Public Const SC_HOTKEY = &HF150
    Public Const SC_HSCROLL = &HF080
    Public Const SC_KEYMENU = &HF100
    Public Const SC_MAXIMIZE = &HF030
    Public Const SC_MINIMIZE = &HF020
    Public Const SC_MOVE = &HF010
    Public Const SC_NEXTWINDOW = &HF040
    Public Const SC_PREVWINDOW = &HF050
    Public Const SC_RESTORE = &HF120
    Public Const SC_SIZE = &HF000
    Public Const SC_VSCROLL = &HF070
    Public Const SC_TASKLIST = &HF130
    Public Const HWND_TOPMOST = -1
    Public Const HWND_NOTOPMOST = -2
    Public Const HWND_TOP = 0
    Public Const SWP_NOSIZE = &H1
    Public Const SWP_NOMOVE = &H2
    Public Const GWL_STYLE = (-16)
    Sub xapplicatieuit()
    ' Remove Excel Items
    Dim hMenu As Long
    hMenu = GetSystemMenu(Application.hwnd, 0)
    Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)          ' Disable X (Close) Application button
    Call DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND)       ' Disable Minimize application button
    Call DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)       ' Disable Maximize application button
    End Sub
    
    Sub xapplicatieaan()
    ' Restore Excel Items
    Dim hMenu As Long
    hMenu = GetSystemMenu(Application.hwnd, 1)
    Call EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND)      ' Enable X (Close) Application button
    Call EnableMenuItem(hMenu, SC_MINIMIZE, MF_BYCOMMAND)   ' Enable Minimize application button
    Call EnableMenuItem(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)   ' Enable Maximize application button
    End Sub

  2. #2
    Registered User
    Join Date
    10-24-2008
    Location
    netherlands
    Posts
    35

    Re: Close button Excel 2003 greyed out can't be undone

    Anybody any ideas?

  3. #3
    Registered User
    Join Date
    10-24-2008
    Location
    netherlands
    Posts
    35

    Re: Close button Excel 2003 greyed out can't be undone

    Last attempt. Anybody

+ 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