View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Executor Executor is offline
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