Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to disable a sheet's x(close) button?

Hi all,
How can I disable a sheet's Close, Small size, Full size/Previous size
buttons (in the top right corner)? I want to manage the sheet from a Userform!
Thanks! Stefi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to disable a sheet's x(close) button?

Protect the workbook (tools=protection=Workbook). Protect at least the
Structure option.

--
Regards,
Tom Ogilvy

"Stefi" wrote in message
...
Hi all,
How can I disable a sheet's Close, Small size, Full size/Previous size
buttons (in the top right corner)? I want to manage the sheet from a

Userform!
Thanks! Stefi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default How to disable a sheet's x(close) button?

Trapping the Close is the easiest: there is an event procedure for
BeforeClose that has a parameter called Cancel; setting Cancel to true in
your procedure will cancel the event, so enter this in the ThisWorkbook
module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' You can put a MsgBox or something here to alert the user if desired
Cancel=True
End Sub

There is also a WindowResize event for the workbook, and you could do this:

Private Sub Workbook_WindowResize(ByVal Wn As Window)
Wn.WindowState = xlMaximized
' Or, your could set any other properties of the window by using Wn,
which is the
' object that holds your Workbook's window
End Sub

The above will prevent the Workbook window (inside the Excel window) from
being set to anything but Maximized, but the Excel app itself could be
resized or minimized. To keep the Excel Window from being changed is much
trickier: there is an Excel Application WindowResize event, too, but to trap
it you would have to declare a custom class an object variable for an
Excel.Application declared "WithEvents" so you can write an event procedure;
if you are not familiar with class modules and event trapping this is an
extensive subject, all I can do in limited time and space is refer you to
other places for info - search this newsgroup or the MSDN library and you
will find more info on this.

HTH - K Dales

"Stefi" wrote:

Hi all,
How can I disable a sheet's Close, Small size, Full size/Previous size
buttons (in the top right corner)? I want to manage the sheet from a Userform!
Thanks! Stefi

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to disable a sheet's x(close) button?

That was a really detailed and understandable explanation!
Thank you very much!
Stefi
P.S. You mean "easiest" for experts and gurus, don't you?

€˛K Dales€¯ ezt Ć*rta:

Trapping the Close is the easiest: there is an event procedure for
BeforeClose that has a parameter called Cancel; setting Cancel to true in
your procedure will cancel the event, so enter this in the ThisWorkbook
module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' You can put a MsgBox or something here to alert the user if desired
Cancel=True
End Sub

There is also a WindowResize event for the workbook, and you could do this:

Private Sub Workbook_WindowResize(ByVal Wn As Window)
Wn.WindowState = xlMaximized
' Or, your could set any other properties of the window by using Wn,
which is the
' object that holds your Workbook's window
End Sub

The above will prevent the Workbook window (inside the Excel window) from
being set to anything but Maximized, but the Excel app itself could be
resized or minimized. To keep the Excel Window from being changed is much
trickier: there is an Excel Application WindowResize event, too, but to trap
it you would have to declare a custom class an object variable for an
Excel.Application declared "WithEvents" so you can write an event procedure;
if you are not familiar with class modules and event trapping this is an
extensive subject, all I can do in limited time and space is refer you to
other places for info - search this newsgroup or the MSDN library and you
will find more info on this.

HTH - K Dales

"Stefi" wrote:

Hi all,
How can I disable a sheet's Close, Small size, Full size/Previous size
buttons (in the top right corner)? I want to manage the sheet from a Userform!
Thanks! Stefi

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to disable a sheet's x(close) button?

Checking the Window option was also necessary, it did exactly what I wanted.
Thanks Tom!
Stefi

€˛Tom Ogilvy€¯ ezt Ć*rta:

Protect the workbook (tools=protection=Workbook). Protect at least the
Structure option.

--
Regards,
Tom Ogilvy

"Stefi" wrote in message
...
Hi all,
How can I disable a sheet's Close, Small size, Full size/Previous size
buttons (in the top right corner)? I want to manage the sheet from a

Userform!
Thanks! Stefi




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
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
Disable the "X" close button in an excel application keepITcool Excel Programming 1 April 18th 05 11:28 AM
Disable Close X Button On Excel Application Celtic_Avenger[_57_] Excel Programming 2 October 31st 04 04:02 PM
Disable Close "X" button on User Forms Celtic_Avenger[_50_] Excel Programming 0 October 11th 04 06:25 PM
Disable close button of Modeless Userform RB Smissaert Excel Programming 2 September 13th 03 09:46 PM


All times are GMT +1. The time now is 04:26 AM.

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

About Us

"It's about Microsoft Excel"