تفضل
وهذا كود اخر غير الموجود بالملف
Sub testSave()
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End Sub
وهذا كود ثالث
Sub CommandButton1_Click()
Application.Quit
ThisWorkbook.Save
End Sub
وهذا كود رابع
Sub SaveAndClose()
ActiveWorkbook.Close SaveChanges:=True
End Sub
واخيرا كود خامس
Private Sub CommandButton2_Click()
Dim WB As Workbook
If Not ThisWorkbook.Saved Then
ThisWorkbook.Save
MsgBox "Your data has been saved.", vbInformation, vbNullString
End If
For Each WB In Application.Workbooks
If Not WB.Saved Then
If MsgBox("You are about to exit the application. The workbook named """ & WB.Name & """ is not saved. Would you like to save """ & WB.Name & """ before it closes?", vbQuestion Or vbYesNo Or vbDefaultButton1, "Save Workbook...?") = vbYes Then
WB.Close SaveChanges:=True
DoEvents
Else
WB.Close SaveChanges:=False
End If
End If
Next
Application.Quit
End Sub
save & close.xlsm