1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Sub Macro9()
'
' Macro9 Macro
'
'
If Cells(1, 4).Value = "SPONTANEE" Then
If MsgBox("Opération irréversible. Souhaitez-vous continuez ?", vbQuestion + vbYesNo, "QUESTION ...") = vbYes Then
nom = Format(Date, "yyyy-mm-dd") & " " & Format(Time, "hh-mm") & " " & " SPONTANEE " & ActiveWorkbook.Name
ActiveWorkbook.SaveCopyAs ActiveWorkbook.Path & "\" & nom
rep = MsgBox("Votre commande spontannée est sauvegardée sous le nom :" & vbCrLf & vbCrLf & " " & nom, vbYes + vbInformation, "Copie sauvegarde commande")
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("A5:H1000").Select
Selection.ClearContents
Range("J3").Select
ActiveCell.FormulaR1C1 = "CLOTUREE"
Range("A5").Select
ThisWorkbook.Close SaveChanges:=False
MsgBox (" Commande spontannée sauvegardée. Fermeture d'excel.")
Application.Quit
Else
Else
If MsgBox("Attention ! Opération irréversible." & vbCrLf & vbCrLf & "Souhaitez-vous clôturer la commande ?", vbQuestion + vbYesNo, "QUESTION ...") = vbYes Then
nom = Format(Date, "yyyy-mm-dd") & " " & Format(Time, "hh-mm") & " " & ActiveWorkbook.Name
ActiveWorkbook.SaveCopyAs ActiveWorkbook.Path & "\" & nom
rep = MsgBox("Votre commande est sauvegardée sous le nom :" & vbCrLf & vbCrLf & " " & nom, vbYes + vbInformation, "Copie sauvegarde commande")
Cells(1, 6) = Date & " " & Time
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("D1").Select
Selection.ClearContents
Range("A5:H1000").Select
Selection.ClearContents
Range("J4") = Application.UserName
Range("A5").Select
ActiveWorkbook.Save
MsgBox ("Commande cloturée, ouverture d'une commande vierge...")
Range("A5").Select
Else
End If
End Sub |
Partager