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 75
| Sub Archivage_Devis()
Dim chemin$, Sep$, nom$, chm$, Lks, B
chemin = ThisWorkbook.Path
PathSep = Application.PathSeparator
nom = [D8] & "-" & Year([E3]) & "-" & Format([E3], "mmm") & "-" & Format([K5], "0000") & ".xlsx"
'---------------------Création du fichier temporaire
If [K5] = "" Then MsgBox "Veuillez saisir en cellule K5 le numéro du devis", , "Création abandonnée !": Exit Sub
If MsgBox(" Si le devis est entièrement édité, veuillez confirmer" & vbCrLf & vbCrLf & _
" l'archivage du devis n° " & nom, vbYesNo, " Veuillez confirmer pour poursuivre,") = vbYes Then
Application.EnableEvents = False
Application.DisplayAlerts = False '-------Annulation des alertes
'---------------------Nom du fichier à créer extension xlsx
Sheets("Devis").Copy
For Each B In ActiveSheet.Buttons
B.Delete
Next
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
Lks = ActiveWorkbook.LinkSources()
If Not IsEmpty(Lks) Then
For i = 1 To UBound(Lks): ActiveWorkbook.BreakLink Name:=Lks(i), Type:=xlExcelLinks: Next i
End If
chm = chemin & PathSep & "Archives Devis" & PathSep & nom
ActiveWorkbook.SaveAs chm, FileFormat:=xlOpenXMLWorkbook
ActiveWindow.Close
'---------------------Après l'archivage le fichier se réinitialise
Sheets("Devis").Range("E3,E4,A13:G17,A19:F22,G27").ClearContents
Sheets("Devis").Range("K5").Value = Sheets("Devis").Range("K5").Value + 1
Application.DisplayAlerts = True '-------rétablissement des alertes
Application.EnableEvents = True
End If
Application.Goto [K5]
ActiveWorkbook.Save
End Sub
Sub Archivage_Factures()
Dim chemin$, Sep$, nom$, chm$, Lks, B
chemin = ThisWorkbook.Path
PathSep = Application.PathSeparator
nom = [D8] & "-" & Year([E3]) & "-" & Format([E3], "mmm") & "-" & Format([K5], "0000") & ".xlsx"
'---------------------Création du fichier temporaire
If [K5] = "" Then MsgBox "Veuillez saisir en cellule K5 le numéro de la facture", , "Création abandonnée !": Exit Sub
If MsgBox(" Si la facture est entièrement éditée, veuillez confirmer" & vbCrLf & vbCrLf & _
" l'archivage de la facture n° " & nom, vbYesNo, " Veuillez confirmer pour poursuivre,") = vbYes Then
Application.EnableEvents = False
Application.DisplayAlerts = False '-------Annulation des alertes
'---------------------Nom du fichier à créer extension xls
Sheets("Facture").Copy
For Each B In ActiveSheet.Buttons
B.Delete
Next
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
Lks = ActiveWorkbook.LinkSources()
If Not IsEmpty(Lks) Then
For i = 1 To UBound(Lks): ActiveWorkbook.BreakLink Name:=Lks(i), Type:=xlExcelLinks: Next i
End If
chm = chemin & PathSep & "Archives Factures" & PathSep & nom
ActiveWorkbook.SaveAs chm, FileFormat:=xlOpenXMLWorkbook
ActiveWindow.Close
'---------------------Après l'archivage le fichier se réinitialise
Sheets("Facture").Range("E3,E4,A14:G21,F24:G24").ClearContents
Sheets("Facture").Range("K5").Value = Sheets("Facture").Range("K5").Value + 1
Application.DisplayAlerts = True '-------rétablissement des alertes
Application.EnableEvents = True
End If
Application.Goto [K5]
ActiveWorkbook.Save
End Sub |