Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bon Bon is offline
external usenet poster
 
Posts: 23
Default Any vba code to disable only close button in Excel workbook, please?

Dear all

Could anyone give me some sample code on disabling the close button in
Excel workbook?

I tried the Tool - Protect - Check Windows method. But, it will
disable the maximize and
minimize buttons as well. Moreover, it will minimize the workbook.

Please give me some advices. thanks


Cheers
Bon

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Any vba code to disable only close button in Excel workbook, please?

Hi,

You can use the BeforeClose event of the worrkbook using VBA:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Are you sure", vbQuestion + vbYesNo, "Close the book") =
vbNo Then
Cancel = True
End If
End Sub

If you use it like this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub

You will nevere be able to close the workboor or end Excel on a normal
way!

HTH

Executor

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 Close Window button of the worksheet yangyh[_7_] Excel Programming 0 September 14th 05 05:04 AM
How to disable a sheet's x(close) button? Stefi Excel Programming 4 May 6th 05 01:21 PM
Disable Close X Button On Excel Application Celtic_Avenger[_57_] Excel Programming 2 October 31st 04 04:02 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:56 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"