Sub ArchiverALL()
' Loop to cycle through each cell in the specified range.
For Each x In Range("b24:b55")
' Change the text in the range to uppercase letters.
x.Value = UCase(x.Value)
Next
For Each Item In Sheets("FactureALL").Range("B24:B55")
If Item.Value = "" Then
Else
Dim dlg As Integer
With Feuil4
dlg = .Range("A" & .Rows.Count).End(xlUp).Row + 1
Ligne_origine = Item.Row
.Range("A" & dlg) = Sheets("FactureALL").Range("A17")
.Range("B" & dlg) = Sheets("FactureALL").Range("B20")
.Range("c" & dlg) = Sheets("FactureALL").Range("G12")
.Range("d" & dlg) = Sheets("FactureALL").Range("G13")
.Range("e" & dlg) = Sheets("FactureALL").Range("G14")
.Range("f" & dlg) = Sheets("FactureALL").Range("G15")
.Range("g" & dlg) = Sheets("FactureALL").Range("B21")
.Range("h" & dlg) = Sheets("FactureALL").Range("F56")
.Range("i" & dlg) = Sheets("FactureALL").Range("I59")
.Range("k" & dlg) = Sheets("FactureALL").Range("I57")
.Range("l" & dlg) = Sheets("FactureALL").Range("h20")
.Range("m" & dlg) = Sheets("FactureALL").Range("F60")
.Range("p" & dlg) = Sheets("FactureALL").Range("C21")
.Range("q" & dlg) = Sheets("FactureALL").Range("a21")
.Range("o" & dlg) = Sheets("FactureALL").Range("B" & Ligne_origine)
.Range("n" & dlg) = Sheets("FactureALL").Range("a" & Ligne_origine)
.Range("j" & dlg) = Sheets("FactureALL").Range("h" & Ligne_origine)
'.Range("E" & dlg) = Sheets("Facture").Range("C3")
End With
End If
Next Item
With ActiveWorkbook.ActiveSheet
On Error Resume Next
For II = 2 To 2
Next
On Error GoTo 0
.Range("A1").Select
End With
Public Function DossierExiste(MonDossier As String)
If Len(Dir(MonDossier, vbDirectory)) > 0 Then
DossierExiste = True
Else
DossierExiste = False
End If
End Function
Dim Chemin, Chemin1, Chemin2 As String
Dim Fichier As String
Fichier = "Facture_" & Sheets("FactureALL").Range("B21") & Sheets("FactureALL").Range("C21") & "_" & Sheets("FactureALL").Range("G12") & "_" & Sheets("FactureALL").Range("B20") & ".pdf"
Chemin1 = "C:\Users\OneDrive\Documents\Factures\2023\"
Chemin2 = "C:\Users\OneDrive\Documents\Factures\2000\"
If DossierExiste(Chemin1) Then 'si le chemin 1 existe
Chemin = Chemin1 'on utilise le chemin1
Else
Chemin = Chemin2 'sinon on prend le chemin 2 ==> à noter ici qu'on a pas vérifié s'il existait aussi..??
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Chemin & Fichier & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, From:=2, To:=1, OpenAfterPublish:=False
' Message de confirmation
MsgBox ("Création du fichier PDF effectué" & vbCrLf & vbCrL&"Objectif Ma : 2827")
' Effacer Macro
With Sheets("FactureALL")
.Range("B20,A24:A55,B24:B55,H57,k2").ClearContents
End With
With Sheets("FactureFR")
.Range("B21") = .Range("B21") + 1
End With
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("B20").Select
Sheets("FactureALL").Select
End Function