Pillotage d'Excel via VB6 (besoin d'aide)

Résolu
jex0519 Messages postés 10 Date d'inscription jeudi 27 septembre 2007 Statut Membre Dernière intervention 9 décembre 2008 - 26 nov. 2008 à 18:41
jex0519 Messages postés 10 Date d'inscription jeudi 27 septembre 2007 Statut Membre Dernière intervention 9 décembre 2008 - 1 déc. 2008 à 17:25
Bonjour à tous!

Voilà je vous présente mon problème:

Je suis débutant en VB et je développe un logiciel de réservation...

J'aimerai pouvoir faire appel à Excel via VB pour pouvoir créer de jolie facture...

En gros j'aimerai via VB ouvrir un fichier Excel qui existera déjà et qui contiendra une jolie mise en page pour la facture... Et ensuite pouvoir completer ce fichier sans détruire la mise en page, les couleurs, etc... Et ensuite sauvegarder ce fichier sous un autre nom afin que le modèle de départ puisse servir encore et encore... Donc en gros a chaque fois j'ouvre le modèle je le complète et j'enregistre sous un autre nom afin de conserver toute les facture sous des fichiers différents...

Le problème est que je commence à me débrouiller en VB mais que je ne sais pas du tout comment piloter Excel afin de faire tout cela...

Merci de votre aide

4 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
27 nov. 2008 à 22:14
voyons voir....

ouvrir un fichier vide ? = > http://www.codyx.org/snippet_comment-ouvrir-classeur-excel-vierge-depuis-vb6_202.aspx

ouvrir fichier existant => http://www.codyx.org/snippet_renommer-feuille-classeur-excel_243.aspx
                                    http://www.codyx.org/snippet_ouvrir-fichier-word-ou-excel-est-ouvert-copie_313.aspx
                                    http://www.codyx.org/snippet_ouvrir-fichier-excel-dans-nouvelle-session-si-session_685.aspx

on mélange le tout, on refait notre petite tambouille.....



<hr />
'    OUVRIR UN FICHIER MODÈLE EXCEL, L'ALTÉRER, ENREGISTRER LES
MANIPULATIONS SOUS UN AUTRE NOM
'    http://www.codyx.org/snippet_ouvrir-fichier-modele-excel-alterer-enregistrer-manipulations-sous_742.aspx#2209
'    Posté par [ PCPT ] le 27/11/2008
<hr />




Sub 
ExempleModeleToXls()


'   fichiers
modèle et résultat

    Const sSourcePathXls As String  = "C:\modele.xls"
    Const sDestPathXls As String =  "C:\sauvegarde.xls"
'   déclare et
crée l'instance excel
    Dim oAppExcel As New Excel.Application
    
'  
visible, pas de message, et attache le modèle
    With oAppExcel
        .Visible = True
        .DisplayAlerts = False
        .Workbooks.Open FileName:=sSourcePathXls, Editable:=False
    End With

'   sélection feuille
1, on va remplir la date (C6) et la ville (C7), par exemple
    With oAppExcel
        .Worksheets("Feuil1").Select
        .Cells(6, 3) = CStr(Date)
        .Range("C7").Value = "Paris"
    End With
    
    
'  
sélection feuille 2, on va colorer une ligne sur 2 (pourquoi
pas...)
    oAppExcel.Worksheets("Feuil2").Select
    Dim i As Integer
    For i = 1 To 30
        If (i And 1) = 0 Then
            oAppExcel.Rows(i).Select
            With oAppExcel.Selection.Interior
                .Pattern = xlSolid
                .PatternColorIndex = xlAutomatic
                .Color = 255
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    Next i
'   on sélectionne la première
cellule du premier classeur
    oAppExcel.Worksheets("Feuil1").Select
    oAppExcel.Range("A1").Select
'   on enregistre une copie
du modèle modifié
    oAppExcel.ActiveWorkbook.SaveAs sDestPathXls
'   ferme excel et nettoie l'instance
    oAppExcel.Application.Quit
    Set oAppExcel = Nothing
End Sub





'----------------------------------------------------------------



'Remarques :


'nécessite la référence Microsoft Excel 9.0 Object Library (ou
supérieur)









j'ai pas ajouté grand chose à ce qui était présent
++

<hr size ="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp 
3
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
27 nov. 2008 à 00:42
salut,

tu trouveras différents exemples sur CODYX.ORG

regarde dans la partie VBA à gauche
(les SNIPPETS étant multi-langages, presque tous ceux en VBA sont aussi en VB6, souvent liés alors à excel)
++

<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp 
0
jex0519 Messages postés 10 Date d'inscription jeudi 27 septembre 2007 Statut Membre Dernière intervention 9 décembre 2008
27 nov. 2008 à 21:16
je trouve rien qui puisse m'aider
0
jex0519 Messages postés 10 Date d'inscription jeudi 27 septembre 2007 Statut Membre Dernière intervention 9 décembre 2008
1 déc. 2008 à 17:25
Merci beaucoup!
Grace a tout ça j'ai bien avancé...

mais j'ai encore un petit problème... le process EXCEL.EXE reste en mémoire après la création d'une facture, alors à la création de la facture suivante ça plante...

Voici mon code si ça peut aider:
il est composer d'un sub facture qui va créer le fichier excel et le compléter des info de la database et d'un autre sub création qui est enfait une macro enregistrée sur excel qui fait juste une mise en page de la facture...

Sub facturer()

    On Error GoTo 10
    MkDir "C:\facturier"

10:
   'facturation avec création de la facture en fichier excel
    Set facture = New excel.Application 'ouvre excel
    facture.Visible = False
    facture.Workbooks.Add 'ouvre un nouveau classeur
   
   
   
   
    creation
   
    'envoi des info client dans la facture
    adors4.Open "select * from client where [num] = " & DataCombo1.BoundText, db, adOpenDynamic, adLockPessimistic
    nom = adors4.Fields("nom")
    prénom = adors4.Fields("prénom")
    adresse = adors4.Fields("adresse")
    code = adors4.Fields("code postal")
    ville = adors4.Fields("ville")
    adors4.Close
    facture.Range("D7").Value = nom
    facture.Range("E7").Value = prénom
    facture.Range("D8").Value = adresse
    facture.Range("D9").Value = code
    facture.Range("E9").Value = ville
   
    facture.Range("A16").Value = Now
   
    adors4.Open "select * from Réservation where num=(select max(num) from réservation)", db, adOpenDynamic, adLockPessimistic
    num = adors4.Fields("num")
    dateDeb = adors4.Fields("dateDeb")
    dateFin = adors4.Fields("dateFin")
    numEmplacement = adors4.Fields("numEmplacement")
    parking = adors4.Fields("parking")
    elec = adors4.Fields("elec")
    adors4.Close
    facture.Range("B16").Value = num
    facture.Range("A20").Value = dateDeb
    facture.Range("B20").Value = dateFin
   
    If parking = 1 Then
    facture.Range("D20").Value = "20,00€"
    Else
    facture.Range("D20").Value = "0,00€"
    End If
   
    If elec = 1 Then
    facture.Range("E20").Value = "50,00€"
    Else
    facture.Range("E20").Value = "0,00€"
    End If
   
    adors4.Open "select * from emplacement where [num] = " & DataCombo2.Text, db, adOpenDynamic, adLockPessimistic
    type1 = adors4.Fields("type")
    capacité = adors4.Fields("capacité")
    adors4.Close
    facture.Range("C20").Value = "Emplacement n° " & numEmplacement & " " & type1
    facture.Range("F20").Value = capacité
   
    adors4.Open "select * from tarif where [type] = '" & type1 & "'", db, adOpenDynamic, adLockPessimistic
    prix = adors4.Fields("prix")
    adors4.Close
    facture.Range("G20").Value = prix
   
    total = capacité * prix * Combo1.Text
   
    If parking = 1 Then
    total = total + 20
    End If
   
    If elec = 1 Then
    total = total + 50
    End If
   
    facture.Range("H20").Value = total
    facture.Range("C25").Value = total
   
   
    facture.Visible = True
   
    'sauvegarde
    ChDir "C:"
    ActiveWorkbook.SaveAs FileName:="C:\facturier\fact-" & num & ".xls", FileFormat:=xlNormal _
    , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False
   
    'apercu impression
    ActiveWindow.SelectedSheets.PrintPreview
   
    facture.Workbooks.Close
    facture.Application.Quit
    Set facture = Nothing

   
   
   
End Sub
-----------------------------
Sub creation()

    Range("A1").Select
    ActiveCell.FormulaR1C1 = "CamPing-Pong"
    Range("A1").Select
    With Selection.Font
        .name = "Arial"
        .Size = 20
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    With Selection.Font
        .name = "Berlin Sans FB Demi"
        .Size = 20
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Selection.Font.ColorIndex = 41
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "rue du camping 19"
    Range("A3").Select
    ActiveCell.FormulaR1C1 = "7000 Mons"
    Range("A4").Select
    ActiveCell.FormulaR1C1 = "Tél. : 065/19.05.19"
    Range("A5").Select
    ActiveCell.FormulaR1C1 = "info@campingpong.be"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = ""
    Range("A13").Select
    ActiveCell.FormulaR1C1 = "Facture"
    Range("A13").Select
    Selection.Font.Bold = True
    With Selection.Font
        .name = "Arial"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Range("A1").Select
    With Selection.Font
        .name = "Berlin Sans FB Demi"
        .Size = 25
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 41
    End With
    Range("A15").Select
    ActiveCell.FormulaR1C1 = "Date et heure"
    Range("B15").Select
    ActiveCell.FormulaR1C1 = "N°"
    Columns("A:A").Select
    Selection.ColumnWidth = 14.71
    Selection.ColumnWidth = 12.86
    Range("A15:B16").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Range("A18:G18").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
        '.LineStyle = xlContinuous
        .Weight = xlThin
        '.ColorIndex = xlAutomatic
    End With
    Range("A18").Select
    ActiveCell.FormulaR1C1 = "Date de début"
    Range("B18").Select
    ActiveCell.FormulaR1C1 = "Date de fin"
    Range("C18").Select
    ActiveCell.FormulaR1C1 = "Emplacement"
    Range("D18").Select
    ActiveCell.FormulaR1C1 = "Parking"
    Range("E18").Select
    ActiveCell.FormulaR1C1 = "Electricité"
    Range("F18").Select
    ActiveCell.FormulaR1C1 = "Prix par personne"
    Range("G18").Select
    ActiveCell.FormulaR1C1 = "Prix par personne"
    Range("F18").Select
    ActiveCell.FormulaR1C1 = "Capacité"
    Range("H18").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    Selection.Borders(xlEdgeBottom).LineStyle = xlNone
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    ActiveCell.FormulaR1C1 = "Total"
    Columns("C:C").Select
    Columns("B:B").ColumnWidth = 13.14
    Columns("C:C").EntireColumn.AutoFit
    Selection.ColumnWidth = 27
    Columns("D:D").EntireColumn.AutoFit
    Columns("E:E").EntireColumn.AutoFit
    Columns("F:F").EntireColumn.AutoFit
    Columns("G:G").EntireColumn.AutoFit
    Range("G18").Select
    ActiveCell.FormulaR1C1 = "Prix " & Chr(10) & "par personne"
    With ActiveCell.Characters(Start:=1, Length:=18).Font
        .name = "Arial"
        .FontStyle = "Normal"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Range("A15:B15").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A18:H18").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
        '.LineStyle = xlContinuous
        .Weight = xlThin
        '.ColorIndex = xlAutomatic
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    'Range("A15:B15,A18:H18").Select
    Range("A18").Activate
    With Selection.Font
        .name = "Arial"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    With Selection.Font
        .name = "Arial"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Selection.Font.Bold = True
    Range("B18").Select
    Columns("A:A").EntireColumn.AutoFit
    Columns("A:A").ColumnWidth = 19.71
    Columns("B:B").ColumnWidth = 20.14
    Columns("B:B").ColumnWidth = 17.57
    Columns("A:A").ColumnWidth = 11.71
    Range("B1").Select
    Columns("A:A").ColumnWidth = 14.71
    Columns("B:B").ColumnWidth = 14.14
    Columns("B:B").ColumnWidth = 14.29
    Columns("B:B").EntireColumn.AutoFit
    Columns("B:B").ColumnWidth = 13.29
    Columns("B:B").ColumnWidth = 15.29
    Columns("D:D").Select
    Columns("D:D").EntireColumn.AutoFit
    Columns("E:E").EntireColumn.AutoFit
    Columns("F:F").EntireColumn.AutoFit
    Range("B1").Select
    Columns("G:G").EntireColumn.AutoFit
    Columns("H:H").EntireColumn.AutoFit
    Columns("H:H").Select
    Selection.ColumnWidth = 11.43
    Selection.ColumnWidth = 13.14
    Range("A18:H22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    Range("A19:H22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("A19:A22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("B19:B22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("C19:C22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("D19:D22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("E19:E22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("F19:F22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("G19:G22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Application.CommandBars("Borders").Visible = False
    Range("A25:B26").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
    ActiveCell.FormulaR1C1 = "Total à payer:"
    Range("A25:B26").Select
    ActiveCell.FormulaR1C1 = " "
    Range("A25:B26").Select
    ActiveCell.FormulaR1C1 = "Total à payer : "
    Range("C25:C26").Select
    Range("C26").Activate
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
    Range("A13").Select
    With Selection.Font
        .name = "Arial"
        .Size = 13
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Range("A1").Select
    With Selection.Font
        .name = "Berlin Sans FB Demi"
        .Size = 30
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 41
    End With
    Range("A25:B26").Select
    With Selection.Font
        .name = "Arial"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Selection.Font.Bold = True
    Selection.Font.Underline = xlUnderlineStyleSingle
    Selection.Font.ColorIndex = 3
    Range("A25:B26").Select
    ActiveCell.FormulaR1C1 = "TOTAL A PAYER : "
    Range("C25:C26").Select
    With Selection.Font
        .name = "Arial"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Selection.Font.Bold = True
    Selection.Font.ColorIndex = 3
    Range("A25:C26").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = xlAutomatic
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("C25:C26").Select
    Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    Range("D26").Select
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.78740157480315)
        .RightMargin = Application.InchesToPoints(0.78740157480315)
        .TopMargin = Application.InchesToPoints(0.984251968503937)
        .BottomMargin = Application.InchesToPoints(0.984251968503937)
        .HeaderMargin = Application.InchesToPoints(0.511811023622047)
        .FooterMargin = Application.InchesToPoints(0.511811023622047)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        '.PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = True
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
    End With
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.78740157480315)
        .RightMargin = Application.InchesToPoints(0.78740157480315)
        .TopMargin = Application.InchesToPoints(0.984251968503937)
        .BottomMargin = Application.InchesToPoints(0.984251968503937)
        .HeaderMargin = Application.InchesToPoints(0.511811023622047)
        .FooterMargin = Application.InchesToPoints(0.511811023622047)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        '.PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
    End With
   
End Sub
0
Rejoignez-nous