Sub Dupliquer_facture()
''''''''''''Application.ScreenUpdating = False
Application.ScreenUpdating = True
Range("I14").Select
Selection.Copy
Dim Recf, Compar, Y, Msg
Set Recf = Application.FileSearch
With Recf
Compar = InputBox("Fichiers dont le nom commence par :" & _
Chr(13) & "(saisissez * pour obtenir tous les " & _
"classeurs du répertoire)", "Classeurs commençant par...")
If Compar <> "" Then
.LookIn = "C:\Users\Philippe\Mes documents\Archives\Factures"
.Filename = Compar & "*.*"
If .Execute > 0 Then
MsgBox .FoundFiles.Count & " fichier(s) trouvé(s)."
For Y = 1 To .FoundFiles.Count
If MsgBox("Voulez-vous ouvrir " & _
.FoundFiles(Y), vbYesNo) = vbYes Then
Workbooks.Open (.FoundFiles(Y))
Mavariable = ActiveWorkbook.Name
End If
Next Y
Else
Msg = MsgBox("Aucun fichier correspondant à la " & _
"recherche.", , "Désolé...")
End If
End If
End With
Range("E13:E17,I13:I15,C20:C35,E20:E35,G20:G35,H20:H35,I37:I38,H40:H41,H43:H44,H46:H49").Select
For Each cel In Selection
cel.Copy
Windows("Bons de Commande & Facture.xls").Activate
Sheets("Facture").Select
Range(cel.Address).Select
ActiveSheet.Paste
Next cel
Range("I13").Select
Application.DisplayAlerts = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Windows(Mavariable).Activate
ActiveWorkbook.Close savechanges:=True
ActiveSheet.PageSetup.PrintArea = "$B$2:$J$58"
With ActiveSheet.PageSetup
.RightHeader = "Page &P de &N"
.CenterFooter = _
"S.A.R.L au capital de "
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0.196850393700787)
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Zoom = 59
End With
Dim Ligne As Integer
Dim Colonne As Byte
Dim Fin As Integer
Dim nbrCopie As Integer
On Error Resume Next
Fin = Range("C65535").End(xlUp).Row
For Ligne = 1 To Fin
For Colonne = 1 To 5
If Cells(Ligne, Colonne) <> "" Then GoTo Saut
Next Colonne
Rows(Ligne & ":" & Ligne).EntireRow.Hidden = True
Saut:
Next Ligne
nbrCopie = InputBox("Combien de copie voulez-vous faire ?", Title:="Copies")
If nbrCopie = 0 Then
Rows("1:" & Fin).EntireRow.Hidden = False
Exit Sub
Else
ActiveSheet.PageSetup.CenterHeaderPicture.Filename = _
ThisWorkbook.Path & "\Dupli.Gif" ' on charge l'image dupli
'''' ActiveSheet.PageSetup.PrintArea = "" ' définit zone d'impression
ActiveWindow.SelectedSheets.PrintOut Copies:=nbrCopie, Collate:=True
ActiveSheet.PageSetup.CenterHeaderPicture.Filename = "" 'on supprime le filigramme
End If
Rows("1:" & Fin).EntireRow.Hidden = False
Range("Zone_a_remplir_Duplicata_Facture") = Empty
Workbooks("Bons de Commande & Facture").Activate
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub