Impression d'information sur une feuille formalisée

Soyez le premier à donner votre avis sur cette source.

Snippet vu 11 527 fois - Téléchargée 39 fois

Contenu du snippet

Voici un exemple de code que j'ai créer pour le boulot, c'est un code d'impression de données dans une feuilles sécu pour ortho...

Je vous laisse le plaisir de lire

PS: les objet auquels se refere le code existe dans plusieurs forms je ne peut pas vous en dire + , loi du silence "contrat oblige"

@+

Source / Exemple :


Private Sub imprimer_Click()
    Dim resum
    resum = MsgBox("Voulez-vous imprimer la période du plan de traitement ?", vbYesNo, "Imprimer le plan de traitement !")

    If resum = vbYes Then Form1.Fin = 20
    If resum = vbNo Then Form1.Fin = 25

    Form1.CMD.CancelError = True
    On Error GoTo ErrHandler
    Form1.CMD.ShowPrinter
    Dim Msg    ' Déclare la variable.
    On Error GoTo ErrorHandler    ' Définit la gestion
    ' des erreurs.

    Form1.imprim    ' Imprime la feuille.

    Exit Sub
ErrorHandler:
    Msg = "Impossible d'imprimer la feuille."
    MsgBox Msg    ' Affiche le message.
    Resume Next
ErrHandler:
    Exit Sub
End Sub

Sub imprim()
    Open App.Path + "\imprime.cfg" For Input As #1
    Input #1, Couleur_titre
    Input #1, Couleur_sous_titre
    Input #1, Couleur_texte
    Input #1, encrage
    Input #1, traitement
    Input #1, résultat_but
    Input #1, chevron_but
    Input #1, résultat_probléme
    Input #1, chevron_probléme
    Input #1, ID_N
    Input #1, ID_C
    Close #1
    noir = &H0&

    If Form1.Fin = 25 Then ID_C = 0    'n'imprime pas le plan de traitement
    If Form1.Fin = 20 Then ID_C = 1    'imprime le plan de traitement

    Printer.CurrentX = 0
    Printer.CurrentY = 0

    'initialise les données
    diag = "Diagnostic : "
    nom = Form2.nom.Caption
    age = Date1.Value
    sexe = Form2.sexe.Caption
    Ss = Form1.ID_SS.Text
    dent = plan_traitement.Label31.Caption + plan_traitement.Label32.Caption

    Printer.ScaleMode = 6
    Printer.ScaleHeight = 220    '(x)
    Printer.ScaleWidth = 320    '(y)

    'Titre
    Printer.ForeColor = Couleur_titre
    Printer.Font.Charset = 0
    Printer.FontSize = 22
    Printer.CurrentX = Printer.ScaleHeight / 2
    Printer.CurrentY = 0

    'sous-titre
    Printer.ForeColor = Couleur_sous_titre
    Printer.FontUnderline = True
    Printer.Print Form1.Label2.Caption

    'line
    Printer.Line (0, 20)-(220 + 95, 20)
    'nom
    Printer.CurrentY = 25
    Printer.CurrentX = 0
    Printer.FontSize = 12
    Printer.Print Form2.Label57.Caption
    'sexe
    Printer.CurrentY = 25
    Printer.CurrentX = Printer.ScaleHeight - 30
    Printer.Print Form2.Label59(0).Caption
    'age
    Printer.CurrentY = 33
    Printer.Print Label31.Caption
    'sécu
    Printer.CurrentX = Printer.ScaleHeight - 30
    Printer.CurrentY = 33
    Printer.Print Form1.Label14.Caption

    'diagnostic
    Printer.CurrentX = 0
    Printer.CurrentY = 45
    Printer.Print diag
    Printer.CurrentX = 0
    Printer.CurrentY = 82
    Printer.Print Form2.Label23.Caption
    Printer.CurrentX = 0
    Printer.CurrentY = 100
    Printer.Print Form2.Label25.Caption

    'caractéristiques
    Printer.CurrentX = 0
    Printer.CurrentY = 138
    Printer.Print plan_traitement.Frame7.Caption    'caractéristiques du traitement

    'plan traitement

    Printer.CurrentX = 0
    Printer.CurrentY = 160
    Printer.Print plan_traitement.Frame1.Caption    'caractéristique du traitement

    'encrage
    Printer.CurrentX = 190
    Printer.CurrentY = 82
    Printer.Print Form2.Label20.Caption    ' calcul
    Printer.CurrentX = 270
    Printer.CurrentY = 82
    Printer.Print Form2.Label24.Caption    'gogn

    Printer.FontSize = 10
    Printer.CurrentX = 240
    Printer.CurrentY = 126
    Printer.Print Form2.Label13.Caption
    Printer.CurrentX = 246
    Printer.CurrentY = 130
    Printer.Print Form2.Label14.Caption
    Printer.FontSize = 12

    'Cadre but
    Printer.Line (110, 42)-(315, 42)
    Printer.Line (110, 75)-(315, 75)
    Printer.Line (110, 42)-(110, 75)
    Printer.Line (315, 42)-(315, 75)

    'probléme
    Printer.CurrentX = 160
    Printer.CurrentY = 45
    Printer.Print Form2.Label21.Caption

    'but
    Printer.CurrentX = 240
    Printer.CurrentY = 45
    Printer.Print Form2.Label26.Caption

    '**************************************************************************
    'date
    Printer.ForeColor = noir
    Printer.FontUnderline = False
    Printer.CurrentY = 15
    Printer.CurrentX = Printer.ScaleHeight + 30
    Printer.Print Format(Date, " dddd dd mmmm yyyy")
    Printer.ForeColor = Couleur_texte

    'nom
    Printer.CurrentY = 25
    Printer.CurrentX = 50
    Printer.FontSize = 12
    Printer.Print nom
    'sexe
    Printer.CurrentY = 25
    Printer.CurrentX = Printer.ScaleHeight - 3
    Printer.Print sexe
    'age
    Printer.CurrentY = 33
    Printer.CurrentX = 55
    Printer.Print Format(age, " dddd dd mmmm yyyy")
    'sécu
    Printer.CurrentY = 33
    Printer.CurrentX = Printer.ScaleHeight
    Printer.Print Ss

    'line
    Printer.Line (0, 40)-(220 + 95, 40)

    'chevron pb
    Printer.FillColor = chevron_probléme
    Printer.Line (160, 53)-(185, 63)
    Printer.Line (160, 70)-(181, 62)

    'chevron but
    Printer.FillColor = chevron_but
    Printer.Line (240, 53)-(265, 63)
    Printer.Line (240, 70)-(261, 62)

    Printer.FillColor = noir

    'print pb
    Printer.ForeColor = résultat_probléme
    Printer.CurrentX = 150
    Printer.CurrentY = 50
    Printer.Print Form2.Label58.Caption
    Printer.CurrentX = 160
    Printer.CurrentY = 50
    Printer.Print Form2.Label60.Caption
    Printer.CurrentX = 160
    Printer.CurrentY = 57
    Printer.Print Form2.Label61.Caption
    Printer.CurrentX = 185
    Printer.CurrentY = 57
    Printer.Print Form2.Label62.Caption
    Printer.CurrentX = 200
    Printer.CurrentY = 57
    Printer.Print Form2.Label63.Caption
    Printer.CurrentX = 150
    Printer.CurrentY = 66
    Printer.Print Form2.Label64.Caption
    Printer.CurrentX = 150
    Printer.CurrentY = 70
    Printer.Print Form2.Label65.Caption
    Printer.CurrentX = 165
    Printer.CurrentY = 70
    Printer.Print Form2.Label66.Caption
    Printer.CurrentX = 185
    Printer.CurrentY = 70
    Printer.Print Form2.Label67.Caption

    ' Print BUT
    Printer.ForeColor = résultat_but
    Printer.CurrentX = 240
    Printer.CurrentY = 50
    Printer.Print Form2.Label75.Caption
    Printer.CurrentX = 232
    Printer.CurrentY = 55
    Printer.Print Form2.Label74.Caption
    Printer.CurrentX = 255
    Printer.CurrentY = 55
    Printer.Print Form2.Label72.Caption
    Printer.CurrentX = 232
    Printer.CurrentY = 66
    Printer.Print Form2.Label69.Caption
    Printer.CurrentX = 255
    Printer.CurrentY = 66
    Printer.Print Form2.Label68.Caption

    '**********************************************

    Printer.ForeColor = Couleur_texte
    'diagnostique
    Printer.FontSize = 10
    Printer.CurrentX = 20
    Printer.CurrentY = 50
    Printer.Print Form2.classe.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 53
    Printer.Print Form2.e.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 56
    Printer.Print Form2.croissance.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 59
    Printer.Print Form2.sn_fma.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 62
    Printer.Print Form2.Text46.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 65
    Printer.Print Form2.Text47.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 68
    Printer.Print Form2.Text48.Caption
    Printer.CurrentX = 20
    Printer.CurrentY = 71
    Printer.Print Form2.Text49.Caption

    'dent
    Printer.CurrentX = 20
    Printer.CurrentY = 77
    Printer.Print " " + plan_traitement.Label31.Caption + plan_traitement.Label32.Caption    'invisibles

    'diag sque
    Printer.CurrentX = 20
    Printer.CurrentY = 87
    Printer.Print Form2.Label38.Caption + " " + Form2.Text41.Text
    Printer.CurrentX = 20
    Printer.CurrentY = 92
    Printer.Print Form2.Label39.Caption + " " + Form2.Text45.Text

    'diag facial
    Printer.CurrentX = 20
    Printer.CurrentY = 105
    Printer.Print Form2.Label19.Caption

    Printer.CurrentX = 20
    Printer.CurrentY = 110
    Printer.Print Form2.Label34.Caption + " " + Form2.Text42.Text

    Printer.CurrentX = 20
    Printer.CurrentY = 115
    Printer.Print Form2.Label18.Caption

    Printer.CurrentX = 20
    Printer.CurrentY = 120
    Printer.Print Form2.Label36.Caption + " " + Form2.Text43.Text

    Printer.CurrentX = 20
    Printer.CurrentY = 125
    Printer.Print Form2.Label37.Caption + " " + Form2.Text44.Text

    'tableau encrage
    I = 0
    a = 0
    For I = 0 To 9
        a = a + 4
        Printer.Line (200, 85 + a)-(315, 85 + a)
    Next I
    Printer.Line (200, 89)-(200, 85 + a)
    Printer.Line (270, 89)-(270, 85 + a + 16)
    Printer.Line (315, 89)-(315, 85 + a + 16)
    Printer.Line (285, 89)-(285, 85 + a + 16)
    Printer.Line (300, 89)-(300, 85 + a + 16)
    I = 0
    For I = 0 To 3
        a = a + 4
        Printer.Line (270, 85 + a)-(315, 85 + a)
    Next I

    'gogn
    Printer.ForeColor = encrage
    Printer.CurrentX = 303
    Printer.CurrentY = 83
    Printer.Print Form2.Text1.Text    'gogn

    Printer.ForeColor = noir
    Printer.CurrentX = 277
    Printer.CurrentY = 86
    Printer.Print "+"
    Printer.CurrentX = 292
    Printer.CurrentY = 86
    Printer.Print "0"
    Printer.CurrentX = 307
    Printer.CurrentY = 86
    Printer.Print "-"

    'encrage label
    Printer.ForeColor = noir
    Printer.CurrentX = 201
    Printer.CurrentY = 90
    Printer.Print Form2.Label4.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 94
    Printer.Print Form2.Label6.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 98
    Printer.Print Form2.Label5.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 102
    Printer.Print Form2.Label7.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 106
    Printer.Print Form2.Label8.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 110
    Printer.Print Form2.Label9.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 114
    Printer.Print Form2.Label10.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 118
    Printer.Print Form2.Label11.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 122
    Printer.Print Form2.Label12.Caption

    Printer.CurrentX = 201
    Printer.CurrentY = 134
    Printer.Print Form2.Label16.Caption
    Printer.CurrentX = 201
    Printer.CurrentY = 138
    Printer.Print Form2.Label17.Caption

    Printer.ForeColor = encrage
    '+
    Printer.CurrentX = 271
    Printer.CurrentY = 90
    Printer.Print Form2.Text2.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 94
    Printer.Print Form2.Text3.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 98
    Printer.Print Form2.Text4.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 102
    Printer.Print Form2.Text5.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 106
    Printer.Print Form2.Text6.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 110
    Printer.Print Form2.Text7.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 114
    Printer.Print Form2.Text8.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 118
    Printer.Print Form2.Text9.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 122
    Printer.Print Form2.Text10.Text

    '0
    Printer.CurrentX = 286
    Printer.CurrentY = 90
    Printer.Print Form2.Text15.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 94
    Printer.Print Form2.Text16.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 98
    Printer.Print Form2.Text17.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 102
    Printer.Print Form2.Text18.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 106
    Printer.Print Form2.Text19.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 110
    Printer.Print Form2.Text20.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 114
    Printer.Print Form2.Text21.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 118
    Printer.Print Form2.Text22.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 122
    Printer.Print Form2.Text23.Text

    '-
    Printer.CurrentX = 301
    Printer.CurrentY = 90
    Printer.Print Form2.Text28.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 94
    Printer.Print Form2.Text29.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 98
    Printer.Print Form2.Text30.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 102
    Printer.Print Form2.Text31.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 106
    Printer.Print Form2.Text32.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 110
    Printer.Print Form2.Text33.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 114
    Printer.Print Form2.Text34.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 118
    Printer.Print Form2.Text35.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 122
    Printer.Print Form2.Text36.Text

    Printer.CurrentX = 271
    Printer.CurrentY = 126
    Printer.Print Form2.Text11.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 130
    Printer.Print Form2.Text12.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 134
    Printer.Print Form2.Text13.Text
    Printer.CurrentX = 271
    Printer.CurrentY = 138
    Printer.Print Form2.Text14.Text

    Printer.CurrentX = 286
    Printer.CurrentY = 126
    Printer.Print Form2.Text27.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 130
    Printer.Print Form2.Text24.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 134
    Printer.Print Form2.Text25.Text
    Printer.CurrentX = 286
    Printer.CurrentY = 138
    Printer.Print Form2.Text26.Text

    Printer.CurrentX = 301
    Printer.CurrentY = 126
    Printer.Print Form2.Text40.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 130
    Printer.Print Form2.Text37.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 134
    Printer.Print Form2.Text38.Text
    Printer.CurrentX = 301
    Printer.CurrentY = 138
    Printer.Print Form2.Text39.Text

    'caractéristique du traitement
    Printer.ForeColor = Couleur_texte
    Printer.CurrentX = 10
    Printer.CurrentY = 145
    Printer.Print DEP.P1.Text
    Printer.CurrentX = 10
    Printer.CurrentY = 148
    Printer.Print DEP.P2.Text
    Printer.CurrentX = 10
    Printer.CurrentY = 151
    Printer.Print " " + DEP.P3.Text

    'tableau plan
    I = 0
    a = 0
    For I = 0 To 8
        a = a + 4
        Printer.Line (40, 165 + a)-(240, 165 + a)
    Next I
    Printer.Line (40, 169)-(40, 165 + a)
    Printer.Line (200, 169)-(200, 165 + a + 4)
    Printer.Line (240, 169)-(240, 165 + a + 4)
    Printer.Line (200, 169 + a)-(240, 169 + a)

    ' détails
    Printer.ForeColor = noir
    Printer.CurrentX = 41
    Printer.CurrentY = 170
    Printer.Print plan_traitement.Text1.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 174
    Printer.Print plan_traitement.Text9.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 178
    Printer.Print plan_traitement.Text8.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 182
    Printer.Print plan_traitement.Text7.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 186
    Printer.Print plan_traitement.Text6.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 190
    Printer.Print plan_traitement.Text5.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 194
    Printer.Print plan_traitement.Text4.Text
    Printer.CurrentX = 41
    Printer.CurrentY = 198
    Printer.Print plan_traitement.Text24.Text

    'mois
    If ID_C = 1 Then
        Printer.ForeColor = traitement
        Printer.CurrentX = 201
        Printer.CurrentY = 170
        Printer.Print plan_traitement.Text2.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 174
        Printer.Print plan_traitement.Text3.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 178
        Printer.Print plan_traitement.Text10.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 182
        Printer.Print plan_traitement.Text11.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 186
        Printer.Print plan_traitement.Text12.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 190
        Printer.Print plan_traitement.Text13.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 194
        Printer.Print plan_traitement.Text14.Text
        Printer.CurrentX = 201
        Printer.CurrentY = 198
        Printer.Print plan_traitement.Text25.Text
    End If

    'total
    Printer.ForeColor = noir
    Printer.CurrentX = 180
    Printer.CurrentY = 202
    Printer.Print plan_traitement.Label3.Caption    'total
    If ID_C = 1 Then
        Printer.ForeColor = traitement
        Printer.CurrentX = 201
        Printer.CurrentY = 202
        Printer.Print plan_traitement.Text23.Text
    End If

    'bas de page
    Printer.ForeColor = noir
    Printer.Line (0, 211)-(220 + 95, 211)
    Printer.CurrentX = 0
    Printer.CurrentY = 212
    Printer.FontSize = 8
    Printer.Print "ANALYSE DE ROOT  Verssion: "; App.Major; "."; App.Minor; "."; App.Revision
    Printer.CurrentX = (Printer.ScaleHeight / 2) + 10
    Printer.CurrentY = 212
    Printer.FontSize = 8
    Printer.Print App.LegalCopyright
    Printer.CurrentX = Printer.ScaleHeight + 40
    Printer.CurrentY = 212
    Printer.FontSize = 8
    Printer.Print Fiche_cab.Dr1.Caption
    Printer.EndDoc

End Sub

Conclusion :


il n'y aura pas de ZIP lol...

A voir également

Ajouter un commentaire

Commentaires

Commenter la réponse de BlackWizzard

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.