fenec
XLDnaute Impliqué
Bonjour le forum
Venant grâce à l’enregistreur de rajouter la mise en page (en bleu) de ma sauvegarde je m’adresse à vous pour savoir s’il serait possible de la réduire afin de la rendre plus rapide
D’avance merci
Cordialement
Fenec
Private Sub CommandButton10_Click() 'Archiver Bon de Commande avec N° incrémenter
Application.ScreenUpdating = False
NomFichier = ActiveWorkbook.Name
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
Me.Cells.Copy ActiveSheet.[A1]
ActiveSheet.Cells.Clear
With Me.Range("Zone_d_impression")
.Copy ActiveSheet.[B2]
ActiveSheet.[B2].Resize(.Rows.Count, .Columns.Count).Locked = True
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = "$B$2:$J$58"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = "Page &P de &N"
.LeftFooter = ""
.CenterFooter = _
"S.A.R.L au capital "
.RightFooter = ""
.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)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 59
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveSheet.Protect
ActiveSheet.Range("B6").Select
ChDir "C:\Users\Philippe\Documents\Archives\bon de commande"
'fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & Format(Now, " dd-mm-yyyy ""à"" hh""h""mm""mn""ss""s"), "Fichiers Excel,*.xls")
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & " " & Range("I14"), "Fichiers Excel,*.xls")
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
ActiveWorkbook.SaveAs Filename:=fermer
ActiveWorkbook.Close
NonClient = Range("E13")
num = Format(Val(Right(Range("I14"), 3)) + 1, "000")
ActiveSheet.Unprotect
Range("L2") = num
Workbooks("exemple.1.xls").Activate
Range("Zone_a_remplir") = Empty
Range("E13").Select
ActiveWorkbook.Save
Application.ScreenUpdating = True
End With
End Sub
Venant grâce à l’enregistreur de rajouter la mise en page (en bleu) de ma sauvegarde je m’adresse à vous pour savoir s’il serait possible de la réduire afin de la rendre plus rapide
D’avance merci
Cordialement
Fenec
Private Sub CommandButton10_Click() 'Archiver Bon de Commande avec N° incrémenter
Application.ScreenUpdating = False
NomFichier = ActiveWorkbook.Name
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
Me.Cells.Copy ActiveSheet.[A1]
ActiveSheet.Cells.Clear
With Me.Range("Zone_d_impression")
.Copy ActiveSheet.[B2]
ActiveSheet.[B2].Resize(.Rows.Count, .Columns.Count).Locked = True
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = "$B$2:$J$58"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = "Page &P de &N"
.LeftFooter = ""
.CenterFooter = _
"S.A.R.L au capital "
.RightFooter = ""
.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)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 59
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveSheet.Protect
ActiveSheet.Range("B6").Select
ChDir "C:\Users\Philippe\Documents\Archives\bon de commande"
'fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & Format(Now, " dd-mm-yyyy ""à"" hh""h""mm""mn""ss""s"), "Fichiers Excel,*.xls")
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("E13").Value & " " & Range("I14"), "Fichiers Excel,*.xls")
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
ActiveWorkbook.SaveAs Filename:=fermer
ActiveWorkbook.Close
NonClient = Range("E13")
num = Format(Val(Right(Range("I14"), 3)) + 1, "000")
ActiveSheet.Unprotect
Range("L2") = num
Workbooks("exemple.1.xls").Activate
Range("Zone_a_remplir") = Empty
Range("E13").Select
ActiveWorkbook.Save
Application.ScreenUpdating = True
End With
End Sub