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
|