Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disable Close Button | Excel Discussion (Misc queries) | |||
Disable Exit button on a UserForm | Excel Discussion (Misc queries) | |||
How do you disable the Collate button? | Excel Discussion (Misc queries) | |||
Right Click Pivot table - Wizard - Back button is disable | Excel Discussion (Misc queries) | |||
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True | Excel Worksheet Functions |