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
| Sub Enregistre_et_Nouveau()
Dim nom As Workbook
Dim chemin As String, extension As String, nomfichier As String
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
ThisWorkbook.ActiveSheet.Copy
ActiveSheet.UsedRange.Activate
With Selection
.Copy
.PasteSpecial Paste:=xlValues
.Validation.Delete
End With
extension = ".xls"
If ActiveSheet.Name = "ticket" Then
chemin = "C:\Gestion\"
nomfichier = ActiveSheet.Range("D21") & ("-") & Format(Now(), "dd-mm-yy") & extension
End If
With ActiveWorkbook
.SaveAs Filename:=chemin & nomfichier
.Close
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
Dim c As Integer
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
End With
ActiveSheet.PrintOut Copies:=1
With ThisWorkbook
With ActiveSheet
c = .Range("D21").Value
.Range("D21").Value = c + 1
If .Name = "ticket" Then
.Range("A7:D16").ClearContents
End If
End With
.Save
End With
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
End Sub |
Partager