IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

[VBA-E]Imprimer le code en couleur


Sujet :

Macros et VBA Excel

  1. #1
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut [VBA-E]Imprimer le code en couleur
    Bonjour ou rebonjour,

    Est-il possible d'imprimer en couleur le code tel qu'il apparait à l'écran ?
    (càd en vert pour les commentaires...)

    Merci

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2003
    Messages : 52
    Points : 58
    Points
    58
    Par défaut
    oui, si l'imprimante est une imprimante couleur, cela va de soit.

  3. #3
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    Oui, je me doute bien qu'il faut une imprimante couleur...
    J'ai essayé hier au bureau sur deux imprimantes (couleur...) différentes, ça ne fonctionne pas... Y a-t-il sans doute un paramètre à changer ?

  4. #4
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 040
    Points
    20 040
    Par défaut
    Ben moi j'avais en tête que l'on ne pouvais pas imprimer le code en couleur....Une astuce consitant à utiliser l'exemple de ce tutorial :

    Découvrez les Expressions régulières dans le VBA Access par Cafeine

  5. #5
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Tu as raison, bbil, noir et blanc, le code. Mais il me semble bien que j'ai vu passé un code pour l'imprimer en couleur. Je fais une recherche.
    A+

  6. #6
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 040
    Points
    20 040
    Par défaut
    Citation Envoyé par ouskel'n'or
    Tu as raison, bbil, noir et blanc, le code. Mais il me semble bien que j'ai vu passé un code pour l'imprimer en couleur. Je fais une recherche.
    A+
    le code il n'est pas dans le lien que j'ai donné...?

  7. #7
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Mais si bbil, chais pas si c'est vraiment adapté mais c'est bien ça.
    De mon côté j'ai fait une macro dans word en recopiant le code, mais seules les entêtes et fins de sub sont "colorisées". Les remarques posaient un pb chaque fois que j'avais une apostrophe dans le texte alors j'ai renoncé faute d'intérêt pour la chose

  8. #8
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    Bonjour à tous,

    Merci à tous ceux qui sont intervenus pour tenter de trouver une solution...
    J'ai lu avec attention ce qu'il y avait dans le lien proposé par Caféine
    et je suppose que le code est ce qui suit le chapitre IV-D.: La fonction d'export avec coloration syntaxique.
    Je l'ai recopié dans une macro Excel mais il n'y a pas moyen de l'exécuter car la macro ne figure pas dans la liste des macros exécutables.

  9. #9
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Tu veux une idée ?
    Je viens de tester : Tu colles ton code sur le forum, tu fais Prévisualisation du message, tu sélectionnes ton code et tu fais Imprimer Selection...
    Mais tu as intérêt à le passer en taille 3 ou 4...
    Inconvénient : Tu as le titre du forum en entête et l'URL en bas
    Mais tu auras ton code en couleur

  10. #10
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    OK, je vais essayer, mais défense de rire de mon code....

    ce n'est pas tjs très beau à voir...

  11. #11
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    Dim txt1, txt2, txtm As String
    Dim zonechap(15) As String
    Dim prix As Single
    Dim nochap(15), chaplignedeb(15), chaplignefin(15) As Integer
    Dim poschap As Integer
    Dim mn1, mn2, mn3, mn4, mn5 As Integer
    Dim pn1, pn2, pn3, pn4, pn5, dn1, dn2, dn3, dn4, dn5 As Integer
    Dim n1, n2, n3, spy3, numligne, lign_m, lign_lb, lign_db As Integer
     
    Public Sub UserForm_initialize()
    '  initialisation de la userform pour l'insertion des postes
    '------------------------------------------------------------
    SpinButton1.Min = 1
    SpinButton1.Max = 10000
    SpinButton1.Value = Worksheets("database").Cells(2, 15)
    TextBox1.Value = Worksheets("database").Cells(2, 15)
    ListBox1.ColumnCount = 7
    ListBox1.ColumnWidths = "0.5 cm;0.5 cm;0.8 cm;0.8 cm;1 cm;18 cm;0.5 cm"
    Worksheets("database").Activate
    nochap(1) = Cells(2, 1)
    poschap = 1
    i = 2
    chaplignedeb(1) = 2
    Do While Cells(i, 1) <> ""
        If Worksheets("database").Cells(i, 1) <> nochap(poschap) Then
           poschap = poschap + 1
           nochap(poschap) = Worksheets("database").Cells(i, 1)
           chaplignefin(poschap - 1) = i - 1
           chaplignedeb(poschap) = i
        End If
        i = i + 1
    Loop
    chaplignefin(poschap) = i - 1
    'MsgBox "Il y a " & poschap & "chapitres"
    For i = 1 To poschap
    '    MsgBox "chapitre " & nochap(i)
    Next i
    For i = 1 To poschap
    '    MsgBox "chapitre " & nochap(i) & " de la ligne " & chaplignedeb(i) & " à la ligne " & chaplignefin(i)
        ' txt1 = "database!a" & lignedeb & ":g" & lignefin
        zonechap(i) = "database!a" & chaplignedeb(i) & ":g" & chaplignefin(i)
    '    MsgBox zonechap(i)
    Next i
    '
    'ComboBox1.RowSource = "database!p2:p4" ' initialisation de la combox1 pour les chapitres
    ComboBox1.AddItem "Chap. 2 : Terrassements"
    ComboBox1.AddItem "Chap. 3 : Hydraulique"
    ComboBox1.AddItem "Chap. 4 : Ouvrages d'art"
    '
    'ComboBox4.RowSource = "database!q2:q7" ' initialisation de la combox4 pour les groupes de postes prédéfinis
    ComboBox4.AddItem "Fouilles blindées"
    ComboBox4.AddItem "Dalle gabarit pour la pose provisoire des éléments de support intermédiaire des éléments de viaduc"
    ComboBox4.AddItem "Poutres gabarit"
    ComboBox4.AddItem "Eléments de support intermédiaires des éléments de viaduc"
    ComboBox4.AddItem "Dalle de liaison"
    ComboBox4.AddItem "Eléments de viaduc à gabarit 4.5 m"
    '
    ComboBox5.AddItem "Oui"
    ComboBox5.AddItem "Non"
    '
    Worksheets("metre").Activate
    End Sub
     
    Public Sub ComboBox1_Click() ' sélectionne un chapitre
    ComboBox2.Clear
    ComboBox3.Clear
    chapsel = ComboBox1.Value
        If chapsel = "Chap. 2 : Terrassements" Then
           ListBox1.RowSource = zonechap(1) ' ATTENTION AU N° DE ZONECHAP
           n1 = 2
        ElseIf chapsel = "Chap. 4 : Ouvrages d'art" Then
           ListBox1.RowSource = zonechap(2) ' ATTENTION AU N° DE ZONECHAP
           n1 = 4
        Else
        MsgBox "Veuillez choisir un autre chapitre...."
        ListBox1.RowSource = ""
        End If
    n2 = 0
    For i = 0 To ListBox1.ListCount - 1
      If ListBox1.List(i, 1) <> "" Then
         If ListBox1.List(i, 1) <> n2 Then
            ComboBox2.AddItem ListBox1.List(i, 5)
            n2 = n2 + 1
         End If
      End If
    Next i
    End Sub
     
    Public Sub ComboBox2_Click() ' sélectionne un sous-chapitre
    'Dim txt1 As String
    ComboBox3.Clear
    Select Case n1
           Case 2
                ListBox1.RowSource = zonechap(1) ' ATTENTION AU N° DE ZONECHAP
           Case 4
                ListBox1.RowSource = zonechap(2) ' ATTENTION AU N° DE ZONECHAP
    End Select
    souschapsel = ComboBox2.Value
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.List(i, 5) = souschapsel Then
           n2 = ListBox1.List(i, 1)
           Exit For
        End If
    Next i
    i = 1
    Do Until Worksheets("database").Cells(i, 1) = n1 And Worksheets("database").Cells(i, 2) = n2
    i = i + 1
    Loop
    lignedeb = i
    Do Until Worksheets("database").Cells(i, 1) <> n1 Or Worksheets("database").Cells(i, 2) <> n2
    i = i + 1
    Loop
    lignefin = i - 1
    txt1 = "database!a" & lignedeb & ":g" & lignefin
    ListBox1.RowSource = txt1
    'Worksheets("database").Cells(2, 19) = txt1
    n3 = 0
    For i = 0 To ListBox1.ListCount - 1
      If ListBox1.List(i, 1) <> "" Then
         If ListBox1.List(i, 2) <> n3 Then
            ComboBox3.AddItem ListBox1.List(i, 5)
            n3 = ListBox1.List(i, 2)
         End If
      End If
    Next i
    spy3 = 0
    End Sub
    Public Sub ComboBox3_Click() ' sélectionne un sous-sous-chapitre
    'Dim txt1 As String
    'Dim txt2 As String
    If spy3 = 1 Then
    '   txt1 = Worksheets("database").Cells(2, 19)
       ListBox1.RowSource = txt1
    End If
    'MsgBox txt1
    sousouchapsel = ComboBox3.Value
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.List(i, 5) = sousouchapsel Then
           n3 = ListBox1.List(i, 2)
           'MsgBox n3
           Exit For
        End If
    Next i
    i = 1
    Do Until Worksheets("database").Cells(i, 1) = n1 And Worksheets("database").Cells(i, 2) = n2 And Worksheets("database").Cells(i, 3) = n3
    i = i + 1
    Loop
    lignedeb = i
    Do Until Worksheets("database").Cells(i, 1) <> n1 Or Worksheets("database").Cells(i, 2) <> n2 Or Worksheets("database").Cells(i, 3) <> n3
    i = i + 1
    Loop
    lignefin = i - 1
    'MsgBox lignedeb
    'MsgBox lignefin
    txt2 = "database!a" & lignedeb & ":g" & lignefin
    ListBox1.RowSource = txt2
    'Worksheets("database").Cells(3, 19) = txt2
    spy3 = 1
    End Sub
     
    Public Sub ComboBox4_Click() ' liste des groupes de postes prédéfinis
    Dim gp As String
    'ListBox1.Clear
    gp = ComboBox4.Value
    Select Case gp
           Case "Fouilles blindées"
                Index = 1
                ListBox1.RowSource = "database!a1001:g1012"
           Case "Dalle gabarit pour la pose provisoire des éléments de support intermédiaire des éléments de viaduc"
                Index = 2
                ListBox1.RowSource = "database!a1013:g1016"
           Case "Poutres gabarit"
                Index = 3
                ListBox1.RowSource = "database!a1017:g1023"
           Case "Eléments de support intermédiaires des éléments de viaduc"
                Index = 4
                ListBox1.RowSource = "database!a1024:g1031"
           Case "Dalle de liaison"
                Index = 5
                ListBox1.RowSource = "database!a1032:g1034"
           Case "Eléments de viaduc à gabarit 4.5 m"
                Index = 6
                ListBox1.RowSource = "database!a1035:g1052"
    End Select
    End Sub
     
    Public Sub CommandButton1_Click() ' Afficher la sélection
    Dim msg2 As String
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) = True Then
        msg2 = ListBox1.List(i, 5) & Chr(10) & Chr(10) & "Unité : " & ListBox1.List(i, 6)
        Style = vbOKOnly
        Title = "Intitlé complet du poste"
        Help = ""
        Ctxt = 1000
        response = MsgBox(msg2, Style, Title, Help, Ctxt)
        End If
    Next i
    End Sub
     
    Public Sub CommandButton6_Click() ' efface une ligne du métré
    ligneff = ActiveCell.Row
    msg = "Etes-vous réellement bien sûr à 100 % de vouloir effacer cette ligne du métré ?..."    ' Define message.
    Style = vbYesNo + vbQuestion + vbDefaultButton1    ' Define buttons.
    Title = "Attention !!!"    ' Define title.
    Help = ""    ' Define Help file.
    Ctxt = 1000    ' Define topic
    response = MsgBox(msg, Style, Title, Help, Ctxt)
    If response = vbNo Then Exit Sub
    If response = vbYes Then
       Rows(ligneff).Delete
    End If
    Call MiseAJourThisSheet
    End Sub
     
    Public Sub CommandButton2_Click() ' Insérer la sélection dans le métré
    If ListBox1.ListIndex = -1 Then Exit Sub
    msg = "Etes-vous réellement bien sûr à 100 % de vouloir insérer cette (ou ces) ligne(s) à cet endroit du métré ?" & Chr(13) & "vérifiez la position de la cellule sélectionnée dans le métré..."
    ' Define message.
    Style = vbYesNo + vbQuestion + vbDefaultButton1    ' Define buttons.
    Title = "Attention !!!"
    Help = ""
    Ctxt = 1000
    response = MsgBox(msg, Style, Title, Help, Ctxt)
    If response = vbNo Then Exit Sub
    If response = vbYes Then
    Worksheets("database").Activate
    numligne = Cells(2, 15)
     
    For j = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(j) = True Then
              Worksheets("metre").Activate
              Rows(numligne).Select
              Selection.Insert Shift:=xlDown
              For i = 1 To 12
                  Cells(numligne, i).Select
                  Selection.Interior.ColorIndex = xlNone
              Next i
     
           Sheets("metre").Cells(numligne, 2) = ListBox1.List(j, 0)
           Sheets("metre").Cells(numligne, 3) = ListBox1.List(j, 1)
           Sheets("metre").Cells(numligne, 4) = ListBox1.List(j, 2)
           Sheets("metre").Cells(numligne, 5) = ListBox1.List(j, 3)
           Sheets("metre").Cells(numligne, 6) = ListBox1.List(j, 4)
           Sheets("metre").Cells(numligne, 7) = ListBox1.List(j, 5)
           Sheets("metre").Cells(numligne, 8) = ListBox1.List(j, 6)
     
           For i = 2 To 8
           Worksheets("metre").Activate
              Sheets("metre").Cells(numligne, i).Select
                   With Selection.Font
               .Name = "Arial"
             .Size = 8
             .Strikethrough = False
             .Superscript = False
             .Subscript = False
             .OutlineFont = False
             .Shadow = False
             .Underline = xlUnderlineStyleNone
             .ColorIndex = xlAutomatic
              End With
           Next i
     
           For i = 2 To 6
           Worksheets("metre").Activate
              Sheets("metre").Cells(numligne, i).Select
              With Selection
             .HorizontalAlignment = xlCenter
             .VerticalAlignment = xlTop
             .WrapText = False
             .Orientation = 0
             .AddIndent = False
             .IndentLevel = 0
             .ShrinkToFit = False
             .ReadingOrder = xlContext
             .MergeCells = False
             End With
          Next i
          Worksheets("metre").Activate
          Sheets("metre").Cells(numligne, 7).Select
          With Selection
            .HorizontalAlignment = xlGeneral
            .VerticalAlignment = xlTop
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
          End With
          Worksheets("metre").Activate
          Sheets("metre").Cells(numligne, 8).Select
          With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlTop
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
          End With
        ' on trame si il n'y a pas d'unités
          If Cells(numligne, 8) = "" Then
             For k = 2 To 5
               Cells(numligne, k).Clear
             Next k
             For k = 8 To 12
                 Cells(numligne, k).Select
                 With Selection.Interior
                   .ColorIndex = 15
                   .Pattern = xlSolid
                 End With
             Next k
          End If
        ' et on met la formule dans la dernière colonne si il y a une unité
          If Cells(numligne, 8) <> "" Then
             Cells(numligne, 12).Select
             Application.CutCopyMode = False
             ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-2]"
             With Selection
                 .HorizontalAlignment = xlCenter
                 .VerticalAlignment = xlBottom
                 .WrapText = False
                 .Orientation = 0
                 .AddIndent = False
                 .IndentLevel = 0
                 .ShrinkToFit = False
                 .ReadingOrder = xlContext
                 .MergeCells = False
             End With
             With Selection.Font
                 .Size = 8
             End With
             'Selection.NumberFormat = "[$€-2] #,##0.00"
             Selection.NumberFormat = "#,##0.00"
          End If
        '=========================================================
        ' copie la formule du numéro de poste et met les bordures
        '=========================================================
          Range("A5").Select
          Selection.Copy
          Range("A" & numligne).Select
          ActiveSheet.Paste
    '     Range("A11:K11").Select
          Range("A" & numligne & ": L" & numligne).Select
          Application.CutCopyMode = False
          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
          Worksheets("metre").Activate
          Sheets("metre").Cells(numligne + 1, 1).Select
          numligne = numligne + 1
          Worksheets("database").Cells(2, 15) = numligne
      End If
    Next j
    End If
    Call MiseAJourThisSheet
    End Sub
     
    Public Sub SpinButton1_change() ' Bouton pour changer la ligne d'insertion dans le métré
    With SpinButton1
        .SmallChange = -1
    End With
    TextBox1.Value = SpinButton1.Value
    numligne = SpinButton1.Value
    Worksheets("database").Cells(2, 15) = numligne
    Worksheets("metre").Cells(numligne, 1).Select
    End Sub
     
    Public Sub TextBox1_Change()
    TextBox1.Value = SpinButton1.Value
    End Sub
     
    Public Sub CommandButton4_Click() ' HELP
    msg2 = "Pour toute question ou toute remarque, contactez JMH au 31913"
        Style = vbOKOnly
        Title = "Help"
        Help = ""
        Ctxt = 1000
        response = MsgBox(msg2, Style, Title, Help, Ctxt)
    'MsgBox ("Pour toute question ou toute remarque, contactez JMH au 31913")
    End Sub
     
    Public Sub CommandButton7_Click() 'sélectionne tout
    For j = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(j) = False Then
           ListBox1.Selected(j) = True
        End If
    Next j
    End Sub
     
    Public Sub CommandButton5_Click() ' désélectionne tout
    For j = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(j) = True Then
           ListBox1.Selected(j) = False
        End If
    Next j
    End Sub
    Public Sub CommandButton8_Click() ' visualiser le métré
    Dim titrcol1 As String
    ListBox2.ColumnCount = 9
    ListBox2.ColumnWidths = "0.5 cm;0.5 cm;0.6 cm;0.8 cm;1 cm;17 cm;1 cm;0.8 cm;0.8 cm"
    i = 2
    Do While Worksheets("metre").Cells(i, 7) <> ""
    i = i + 1
    Loop
    nbreligne = i - 1
    txtm = "metre!b4:j" & nbreligne
    'ListBox2.AddItem "N° de code", 0
    ListBox2.RowSource = txtm
    'If ListBox2.ListIndex = -1 Then
    '            ListBox2.ListIndex = 1
    'End If
     
    End Sub
     
    Public Sub ListBox2_Click() ' Visualisation des postes du métré
    'MsgBox ListBox2.List(ListBox2.SelectedItem)
    TextBox8.Value = ""
    'CheckBox1.Caption = ""
    ComboBox5.Value = ""
    'CheckBox1.Value = False
    Label16.Visible = False
    TextBox9.Visible = False
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) = True Then
    '    MsgBox i
        TextBox10.Value = ListBox2.List(i, 5)
        End If
    Next i
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) = True Then
           pn1 = ListBox2.List(i, 0)
           pn2 = ListBox2.List(i, 1)
           pn3 = ListBox2.List(i, 2)
           pn4 = ListBox2.List(i, 3)
           pn5 = ListBox2.List(i, 4)
           Exit For
         End If
    Next i
     
    lign_lb = i
     
    For i = 2 To 2000
           dn1 = Worksheets("database").Cells(i, 1)
           dn2 = Worksheets("database").Cells(i, 2)
           dn3 = Worksheets("database").Cells(i, 3)
           dn4 = Worksheets("database").Cells(i, 4)
           dn5 = Worksheets("database").Cells(i, 5)
           If dn1 = pn1 And dn2 = pn2 And dn3 = pn3 And dn4 = pn4 And dn5 = pn5 Then
              TextBox8.Value = Worksheets("database").Cells(i, 14)
              Exit For
           End If
    Next i
     
    lign_db = i
     
    End Sub
     
    'Public Sub CheckBox1_Change() '                  introduction du bon prix
    'Select Case CheckBox1.Value
    '       Case True: CheckBox1.Caption = "Oui"
    '                   Label16.Visible = False
    '                  TextBox9.Visible = False
    '       Case False: CheckBox1.Caption = "Non"
    '                   Label16.Visible = True
    '                  TextBox9.Visible = True
    'End Select
     
     
    Public Sub ComboBox5_Change() '                introduction du prix
    If ComboBox5.Value = "Oui" Then
                       Label16.Visible = False
                      TextBox9.Visible = False
    End If
     
    If ComboBox5.Value = "Non" Then
                       Label16.Visible = True
                      TextBox9.Visible = True
                      TextBox9.Value = ""
    End If
    End Sub
     
    Public Sub Commandbutton11_click() '     insérer le prix unitaire
    If TextBox8.Value = "" Then
       MsgBox ("IL FAUT UN PRIX UNITAIRE !!!")
       Exit Sub
    End If
    'Select Case CheckBox1.Value
    '       Case True: prix = TextBox8.Value
    '       Case False: prix = TextBox9.Value
    'End Select
    If ComboBox5.Value = "Oui" Then prix = TextBox8.Value
    If ComboBox5.Value = "Non" Then prix = TextBox9.Value
     
    For i = 4 To 65536
           Worksheets("metre").Activate
           mn1 = Worksheets("metre").Cells(i, 2)
           mn2 = Worksheets("metre").Cells(i, 3)
           mn3 = Worksheets("metre").Cells(i, 4)
           mn4 = Worksheets("metre").Cells(i, 5)
           mn5 = Worksheets("metre").Cells(i, 6)
           If mn1 = pn1 And mn2 = pn2 And mn3 = pn3 And mn4 = pn4 And mn5 = pn5 Then
    '          MsgBox "Ligne du métré : " & i
              Worksheets("metre").Cells(i, 10) = prix
              Exit For
           End If
    Next i
    End Sub
     
    Public Sub CommandButton3_Click() ' EXIT
    'msg = "Voulez-vous effacer la worksheet database ?"    ' Define message.
    'Style = vbYesNo + vbQuestion + vbDefaultButton1    ' Define buttons.
    'Title = "Attention !!!"    ' Define title.
    'Help = ""    ' Define Help file.
    'Ctxt = 1000    ' Define topic
    'response = MsgBox(msg, Style, Title, Help, Ctxt)
    'If response = vbYes Then
    '    Application.DisplayAlerts = False
    '    Sheets("database").Select
    '    ActiveWindow.SelectedSheets.Delete
    '    Application.DisplayAlerts = True
    'End If
    Unload UserForm2
    End Sub
     
    Private Sub UserForm_Click()
     
    End Sub

  12. #12
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    Evidemment, ça ne fonctionne pas... C'est désespérant...

    Tout à l'heure, j'ai mis deux lignes de code et ça a fonctionné, et maintenant plus...

  13. #13
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Je ne comprends pas. Il est censé faire quoi ton code ? Imprimer ton code en couleur ?

    Et j'ajoute :
    Pour nous éviter de parcourir tout ton... looooong code, sur quelle ligne l'erreur ? Quelle erreur ? Le message, pas le N°

  14. #14
    Membre régulier
    Inscrit en
    Février 2007
    Messages
    118
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 118
    Points : 74
    Points
    74
    Par défaut
    Le code sert à générer un fichier excel, mieux encore, le composer à partir de différents éléments... Mais la question n'est pas là...
    Mon problème était d'imprimer ce code en couleur comme il apparait dans mon message de 13h04... (là, y a encore des choses à dire, mais bon, maintenant que ça fonctionne, c'est le principal)
    La solution est de sélectionner le code tel qu'il apparait dans le dit message et de le convertir en fichier PDF, puis de l'imprimer...
    Le résultat est d'ailleurs superbe : fond bleu.... et entête forum des développeurs, histoire de ne pas oublier qui sont les meilleurs qui aident les autres...
    Merci à tous et à charge de revanche...

  15. #15
    Nouveau Candidat au Club
    Inscrit en
    Juin 2004
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 1
    Points : 1
    Points
    1
    Par défaut capture d ecran
    bon beeh , je crois ke tu dois faire une capture d ecran, et tu enregistre dans un fichier word par exemple, la tu pourra facilement imprimer avec couleur ton code.

    bin für deine frage immer da !!!! -

  16. #16
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Pourquoi ? Mon idée du mois de décembre ne te plait pas ?

    Edit
    Tu as hiberné qu'on ne te voit que maintenant ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Imprimer les codes VBA en couleur
    Par cafeine dans le forum Contribuez
    Réponses: 0
    Dernier message: 28/12/2011, 15h37
  2. Imprimer le code VBA en couleurs
    Par eliot.raymond dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 22/03/2009, 16h38
  3. Imprimer le code en couleur
    Par ouskel'n'or dans le forum Contribuez
    Réponses: 13
    Dernier message: 22/02/2009, 21h51
  4. Imprimer son code en couleur
    Par morganitos dans le forum Visual C++
    Réponses: 4
    Dernier message: 30/05/2007, 00h28
  5. [VBA-E]Imprimer en couleur
    Par ouskel'n'or dans le forum Macros et VBA Excel
    Réponses: 12
    Dernier message: 02/06/2006, 01h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo