Private Sub CommandButton2_Click()
Dim chemin$
Dim acell, vcell, i As Byte
chemin = "c:\facturation-test\commandes\" 'chemin d'accès à adapter
On Error Resume Next 'par exemple si ComboBox1 est vide
With Workbooks.Add(xlWBATWorksheet).Sheets(1)
.[B1].ColumnWidth = 43.67
.[C1].ColumnWidth = 3.67
.[D1].ColumnWidth = 4.67
.[E1].ColumnWidth = 5.67
.[F1].ColumnWidth = 10.67
.[G1].ColumnWidth = 12.67
.[H1].ColumnWidth = 4
.[B5] = ComboBox1 'en-tête
With .[A1]
.RowHeight = 27
.ColumnWidth = 12.75
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
'""""""""""""""""""""""""""""""""""""""""""""""""""
'Sub autrefaconderemplircellules()issu de staple1600
.Name = ComboBox1
acell = Array("A5", "A6", "B1", "B2", "B3", "B4", "B7", "C1", "C2", "C3", "C4", "C7", "D7", "F2", "F3")
vcell = Array("Fournisseurs", "N° d'offre", "entreprise", "Affaire suivi par : Pascal", "adresse", "cp et ville", "désignation", _
"Bon de commande n°:", "ville le :", "début début travaux:", "référence client", "Unité", "quantité", Date, Date + 40)
With Workbooks.Add(xlWBATWorksheet).Sheets(1)
For i = LBound(acell) To UBound(acell)
.Range(acell(i)) = vcell(i)
Next i
End With
'End Sub
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Range("B1:B7,A5:A6,C1:F4,C7:D7,C5:F5").Borders.LineStyle = 1
Range("C5:F5").MergeCells = True
'suite des mises en forme de la feuille
.Parent.SaveAs chemin & ComboBox1
'.Parent.Close False 'facultatif
End With
End Sub