G
gatarossi
dear all,
I have this code, but if I click in cancel, the worbook closes, and if
I click in yes or in no, I need to click twice to complete the
operation, because after the first click the msgbox apears again. This
code is correct or I'm getting crazy?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim iselection As Integer
iselection = MsgBox("Deseja salvar as alterações realizadas?",
vbYesNoCancel + vbQuestion)
Select Case iselection
Case Is = vbYes
Sheets("acesso").Visible = True
Sheets("Evolução de Horas").Visible = xlVeryHidden
Sheets("aux").Range("d2:d9").ClearContents
ThisWorkbook.Close SaveChanges:=True
Case Is = vbNo
Sheets("aux").Range("d2:d9").ClearContents
ActiveWorkbook.Close SaveChanges:=False
End Select
End Sub
Thanks!
André.
I have this code, but if I click in cancel, the worbook closes, and if
I click in yes or in no, I need to click twice to complete the
operation, because after the first click the msgbox apears again. This
code is correct or I'm getting crazy?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim iselection As Integer
iselection = MsgBox("Deseja salvar as alterações realizadas?",
vbYesNoCancel + vbQuestion)
Select Case iselection
Case Is = vbYes
Sheets("acesso").Visible = True
Sheets("Evolução de Horas").Visible = xlVeryHidden
Sheets("aux").Range("d2:d9").ClearContents
ThisWorkbook.Close SaveChanges:=True
Case Is = vbNo
Sheets("aux").Range("d2:d9").ClearContents
ActiveWorkbook.Close SaveChanges:=False
End Select
End Sub
Thanks!
André.