Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 84
Default Disable X button on excel

Is there anyway you can disable the exit button X in excel 2003 as I
only want the users to close and save the workbook thru a button macro
on the worksheet???

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Disable X button on excel

You can use Workbook_BeforeClose event to force user to close workbook by
pressing a button.

Copy following code to ThisWorkBook code section

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Ok2Close
End Sub

Copy following code to a module

Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
Ok2Close = False
End Sub

Haldun Alay


"pano" , haber iletisinde sunlari
roups.com...
Is there anyway you can disable the exit button X in excel 2003 as I
only want the users to close and save the workbook thru a button macro
on the worksheet???

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 84
Default Disable X button on excel

On Mar 27, 5:08 pm, "Haldun Alay" wrote:
You can use Workbook_BeforeClose event to force user to close workbook by
pressing a button.

Copy following code to ThisWorkBook code section

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Ok2Close
End Sub

Copy following code to a module

Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
Ok2Close = False
End Sub

Haldun Alay

"pano" , haber iletisinde sunlari
roups.com...



Is there anyway you can disable the exit button X in excel 2003 as I
only want the users to close and save the workbook thru a button macro
on the worksheet???


Thanks- Hide quoted text -


- Show quoted text -


Hmm Haldun, this sure does stop the user pressing the X button but I
need it to close the workbook which it does but also close excel down

thanks for the help so far
stephen

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 751
Default Disable X button on excel

To close the application insert this line:

Application.Quit

You can enter it before

Ok2Close = False

HTH
Kostis Vezerides

On Mar 27, 2:45 pm, "pano" wrote:
On Mar 27, 5:08 pm, "Haldun Alay" wrote:



You can use Workbook_BeforeClose event to force user to close workbook by
pressing a button.


Copy following code to ThisWorkBook code section


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Ok2Close
End Sub


Copy following code to a module


Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
Ok2Close = False
End Sub


Haldun Alay


"pano" , haber iletisinde sunlari
roups.com...


Is there anyway you can disable the exit button X in excel 2003 as I
only want the users to close and save the workbook thru a button macro
on the worksheet???


Thanks- Hide quoted text -


- Show quoted text -


Hmm Haldun, this sure does stop the user pressing the X button but I
need it to close the workbook which it does but also close excel down

thanks for the help so far
stephen



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 84
Default Disable X button on excel

On Mar 27, 9:54 pm, "vezerid" wrote:
Toclosethe application insert this line:

Application.Quit

You can enter it before

Ok2Close = False

HTH
Kostis Vezerides

On Mar 27, 2:45 pm, "pano" wrote:



On Mar 27, 5:08 pm, "Haldun Alay" wrote:


You can use Workbook_BeforeClose event to force user tocloseworkbook by
pressing a button.


Copy following code to ThisWorkBook code section


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Ok2Close
End Sub


Copy following code to a module


Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
Ok2Close = False
End Sub


Haldun Alay


"pano" , haber iletisinde sunlari
roups.com...


Is there anyway you can disable the exit button X inexcel2003 as I
only want the users tocloseand save the workbook thru a button macro
on the worksheet???


Thanks- Hide quoted text -


- Show quoted text -


Hmm Haldun, this sure does stop the user pressing the X button but I
need it toclosethe workbook which it does but alsocloseexceldown


thanks for the help so far
stephen- Hide quoted text -


- Show quoted text -


Hmm I have been looking thru the past messages and I found that and
tried it but excel still wont close down am I doing something wrong
here is the code I am using

Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
ChDir "D:\"
ActiveWorkbook.SaveAs Filename:="D:\DWS.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=True
Application.Quit
Ok2Close = False

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Disable X button on excel

You are closing file so macro execution stops...

Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ChDir "D:\"
ActiveWorkbook.SaveAs Filename:="D:\DWS.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=True
ThisWorkbook.Close
Application.Quit
Ok2Close = False

End Sub


"pano" , haber iletisinde sunlari
roups.com...
On Mar 27, 9:54 pm, "vezerid" wrote:
Toclosethe application insert this line:

Application.Quit

You can enter it before

Ok2Close = False

HTH
Kostis Vezerides

On Mar 27, 2:45 pm, "pano" wrote:



On Mar 27, 5:08 pm, "Haldun Alay" wrote:


You can use Workbook_BeforeClose event to force user tocloseworkbook
by
pressing a button.


Copy following code to ThisWorkBook code section


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Ok2Close
End Sub


Copy following code to a module


Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
Ok2Close = False
End Sub


Haldun Alay


"pano" , haber iletisinde sunlari
roups.com...


Is there anyway you can disable the exit button X inexcel2003 as I
only want the users tocloseand save the workbook thru a button
macro
on the worksheet???


Thanks- Hide quoted text -


- Show quoted text -


Hmm Haldun, this sure does stop the user pressing the X button but I
need it toclosethe workbook which it does but alsocloseexceldown


thanks for the help so far
stephen- Hide quoted text -


- Show quoted text -


Hmm I have been looking thru the past messages and I found that and
tried it but excel still wont close down am I doing something wrong
here is the code I am using

Public Ok2Close As Boolean
Sub CloseMacro()
Ok2Close = True
ThisWorkbook.Close
ChDir "D:\"
ActiveWorkbook.SaveAs Filename:="D:\DWS.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=True
Application.Quit
Ok2Close = False

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Disable X button on excel

Put this in the ThisWorkbook Module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If CloseMode = vbFormControlMenu Then
MsgBox "Clicking the X button does not work."
Cancel = True
End If
End Sub

"pano" wrote:

Is there anyway you can disable the exit button X in excel 2003 as I
only want the users to close and save the workbook thru a button macro
on the worksheet???

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
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
Disable Exit button on a UserForm Noemi Excel Discussion (Misc queries) 1 September 14th 06 09:37 PM
How do you disable the Collate button? Trixie Excel Discussion (Misc queries) 0 August 25th 06 04:00 PM
Right Click Pivot table - Wizard - Back button is disable Ashok Excel Discussion (Misc queries) 0 November 16th 05 10:13 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM


All times are GMT +1. The time now is 07:16 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"