Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Closing a worksheet

How do I prevent or disable in code a worksheet close, not a workbook close?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Closing a worksheet

You cannot cancel the deactivate, so you would need to capture the active
worksheet, and then restore that if it is deactivated.

--

HTH

RP

"Sheldon" wrote in message
...
How do I prevent or disable in code a worksheet close, not a workbook

close?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Closing a worksheet

Sheldon,
Do you mean deactivate a worksheet? Try:
Private Sub Worksheet_Deactivate()
Me.Activate
End Sub

Geof.
-----Original Message-----
How do I prevent or disable in code a worksheet close,

not a workbook close?

Thanks
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Closing a worksheet

Hi Sheldon,

A worksheet can not be closed, merely deactivated or hidden.

Try setting the visible property of all but the required sheet to
xlVeryHidden:

Sub Tester()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
If sh.Name < "Permitted Sheet's name" Then
sh.Visible = xlVeryHidden
End If
Next
End Sub

If this approach is not acceptable you could paste something like the
following into the worksheet module:

Private Sub Worksheet_Deactivate()
MsgBox "Only sheet " & Me.Name & " is available", _
vbInformation
Me.Activate
End Sub

---
Regards,
Norman



"Sheldon" wrote in message
...
How do I prevent or disable in code a worksheet close, not a workbook
close?

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Closing a worksheet

I guess I need to be more specific. I want to prevent the automatic action
that takes place when the user clicks on the "X" in the top right of the
worksheet (NOT the workbook - that's ok to use). I have created a macro that
closes the worksheet and does some other operations.

Thanks

"Sheldon" wrote:

How do I prevent or disable in code a worksheet close, not a workbook close?

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Closing a worksheet

Hi Sheldon.

The "X" you refer to closes the workbook, not a sheet. The topmost "X"
closes the Excel Application.

I have created a macro that closes the worksheet


Please show your code! I do not beleive that it is possible to close a
worksheet in isolation from its parent workbook.


---
Regards,
Norman



"Sheldon" wrote in message
...
I guess I need to be more specific. I want to prevent the automatic action
that takes place when the user clicks on the "X" in the top right of the
worksheet (NOT the workbook - that's ok to use). I have created a macro
that
closes the worksheet and does some other operations.

Thanks

"Sheldon" wrote:

How do I prevent or disable in code a worksheet close, not a workbook
close?

Thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Closing a worksheet

I don't know how I can be more explicit. I'm not referring to the TOP,
rightmost "X", which closes the applications. I have several worksheets in
my workbook app. When I need to display two of the worksheets at the same
time, each taking part of the app window, I need to prevent the user from
clicking the worksheet "x" when that sheet is active.
I cannot seem to trap that event.

Thanks
Sheldon

"Norman Jones" wrote:

Hi Sheldon.

The "X" you refer to closes the workbook, not a sheet. The topmost "X"
closes the Excel Application.

I have created a macro that closes the worksheet


Please show your code! I do not beleive that it is possible to close a
worksheet in isolation from its parent workbook.


---
Regards,
Norman



"Sheldon" wrote in message
...
I guess I need to be more specific. I want to prevent the automatic action
that takes place when the user clicks on the "X" in the top right of the
worksheet (NOT the workbook - that's ok to use). I have created a macro
that
closes the worksheet and does some other operations.

Thanks

"Sheldon" wrote:

How do I prevent or disable in code a worksheet close, not a workbook
close?

Thanks




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Closing a worksheet

Protect the Workbook, windows option. This also prevents moving the
windows.

Tools=Protection=Protect Workbook = Choose at least Windows
--
Regards,
Tom Ogilvy

"Sheldon" wrote in message
...
I don't know how I can be more explicit. I'm not referring to the TOP,
rightmost "X", which closes the applications. I have several worksheets

in
my workbook app. When I need to display two of the worksheets at the same
time, each taking part of the app window, I need to prevent the user from
clicking the worksheet "x" when that sheet is active.
I cannot seem to trap that event.

Thanks
Sheldon

"Norman Jones" wrote:

Hi Sheldon.

The "X" you refer to closes the workbook, not a sheet. The topmost "X"
closes the Excel Application.

I have created a macro that closes the worksheet


Please show your code! I do not beleive that it is possible to close a
worksheet in isolation from its parent workbook.


---
Regards,
Norman



"Sheldon" wrote in message
...
I guess I need to be more specific. I want to prevent the automatic

action
that takes place when the user clicks on the "X" in the top right of

the
worksheet (NOT the workbook - that's ok to use). I have created a

macro
that
closes the worksheet and does some other operations.

Thanks

"Sheldon" wrote:

How do I prevent or disable in code a worksheet close, not a workbook
close?

Thanks






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
closing a 2007 worksheet Suzi-Q Excel Discussion (Misc queries) 4 February 12th 08 01:35 AM
macro closing worksheet Jeff Excel Discussion (Misc queries) 1 July 3rd 06 01:58 PM
How do I set the worksheet to save before closing? kodaco Excel Discussion (Misc queries) 1 July 6th 05 06:40 AM
Automatically Closing a worksheet after 10 mins Neil Excel Programming 1 February 9th 04 10:05 AM
closing an excel worksheet inside vb .net Bernie Yaeger Excel Programming 3 November 7th 03 01:53 PM


All times are GMT +1. The time now is 06:22 PM.

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"