![]() |
Vba enable close button
Is there a way to enable the close button in a Workbook ?
Thanks, Martín --- Message posted from http://www.ExcelForum.com/ |
Vba enable close button
Turn off workbook level protection.
-- Regards, Tom Ogilvy "Martín2626 " wrote in message ... Is there a way to enable the close button in a Workbook ? Thanks, Martín --- Message posted from http://www.ExcelForum.com/ |
Vba enable close button
I think you want to disable the close option because it's
already enabled. Here's the whole code for this: Send in Me.Caption into either of the following routines. Make sure you do this on the initialise event for 'DisableActiveDialogMenuControls' '-----------------------------Declarations to Remove Dialog Controls Private Const MF_BYPOSITION As Long = &H400 ''' Deletes the menus byposition (this is our default) Private Const MF_BYCOMMAND As Long = &H0 ''' Deletes the menu by Command ID. This is rarely used and is shown here for information purposes only. Private Const mlNUM_SYS_MENU_ITEMS As Long = 9 ''' This is the number of items on the system menu Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long ' Comments: Deletes the system control menu of the specified window. ' ' Arguments: DialogCaption The caption of the window whose control ' menu you want to delete. If not specified, ' Application.Caption is assumed. ' Public Sub DisableActiveDialogMenuControls(DialogCaption As String) Dim lHandle As Long, lCount As Long On Error Resume Next DialogCaption = DialogCaption & vbNullChar lHandle = FindWindowA(vbNullString, DialogCaption) ' Only continue if the passed window handle isn't zero. If lHandle < 0 Then ' There are 9 items on the application control menu. ' Loop through and disable each one. For lCount = 1 To mlNUM_SYS_MENU_ITEMS ' The nPosition of the DeleteMenu function will always be 0, ' because as we delete each menu item, the next one moves up ' into the first position (index of 0). DeleteMenu GetSystemMenu(lHandle, False), 0, MF_BYPOSITION Next lCount End If End Sub ' Comments: Restores the system control menu of the specified window. ' ' Arguments: szCaption (Optional) The caption of the window whose control ' menu you want to delete. If not specified, ' Application.Caption is assumed. ' Public Sub EnableActiveDialogMenuControls(DialogCaption As String) Dim lHandle As Long On Error Resume Next DialogCaption = DialogCaption & vbNullChar lHandle = FindWindowA(vbNullString, DialogCaption) ' Passing True to the bRevert argument of the GetSystemMenu API restores ' the control menu of the specified window. GetSystemMenu lHandle, True End Sub Regards -----Original Message----- Is there a way to enable the close button in a Workbook ? Thanks, Martín --- Message posted from http://www.ExcelForum.com/ . |
Vba enable close button
|
Vba enable close button
then protect the workbook.
-- Regards, Tom Ogilvy "Martín2626 " wrote in message ... Yes, Thanks. What I want is to disable it. --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 10:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com