Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Vba enable close button

Yes, Thanks. What I want is to disable it

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO DO ENABLE ENABLE THE QUERY PARAMETER BUTTON? CPW Excel Worksheet Functions 1 January 21st 10 06:31 PM
close button does not close goplayoutside Excel Discussion (Misc queries) 1 October 11th 05 03:42 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM
Enable Close button Martín2626[_5_] Excel Programming 0 February 25th 04 09:11 PM


All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"