Tache d'impression, création d'un cartouche

Contenu du snippet

Ce code utilise l'objet printer et permet de créer un cartouche avec des informations (variables globales) prisent dans un fichier.

Source / Exemple :


Dim fichier As String

'''''prereglage
Printer.ScaleMode = vbMillimeters
Printer.Orientation = 2
Printer.PaperSize = 8 'A3

fichier = "c:\app\u101\cfg\ReglageImpression.ini"
'on doit lire le fichier parametre impression
If TestFichierExiste(fichier) = FIC_OK Then
    Call ReadParamImpression(fichier)
Else
    MsgBox ("le fichier param impression n'existe pas!")
    Exit Sub
End If

fichier = "\\10.120.96.227\cfg\config.ini"
If TestFichierExiste(fichier) = FIC_OK Then
    Call ReadFic_Param(fichier)
Else
    MsgBox ("le fichier param n'existe pas !")
End If

G_OffsetX = 0
G_OffsetY = 30

'on vient lire le fichier présence plateau
fichier = "C:\Donnees\Plateau\" & G_NomBalayage & "\" & Fichier_PresencePlateau
Call ImpressionPlateau(fichier)

'on vient lire le fichier défaut
fichier = "C:\Donnees\Plateau\" & G_NomBalayage & "\" & Fichier_Defaut
Call ImpressionDefaut(fichier)

'on vient lire le fichier marque!
fichier = "C:\Donnees\Plateau\" & G_NomBalayage & "\" & Fichier_Marque
Call ImpressionMarque(fichier)

'on trace le contour du balayage
Printer.DrawStyle = vbDashDot
Printer.DrawWidth = 4
Printer.Line (G_OffsetX, G_OffsetY)-(G_OffsetX + G_Longueur / G_Echelle, G_OffsetY + G_Largeur / G_Echelle), , B

Printer.DrawStyle = vbSolid
Printer.DrawWidth = 1
'on trace le cartouche
'1ere ligne
Printer.Line (0, 0)-(50, 10), , B
Printer.Line (50, 0)-(100, 10), , B
Printer.Line (100, 0)-(150, 10), , B
Printer.Line (150, 0)-(200, 10), , B
Printer.Line (200, 0)-(230, 10), , B
Printer.Line (230, 0)-(240, 10), G_TabCouleurDefaut(1), BF
Printer.Line (240, 0)-(270, 10), , B
Printer.Line (270, 0)-(280, 10), G_TabCouleurDefaut(4), BF

'2eme ligne
Printer.Line (0, 10)-(50, 20), , B
Printer.Line (50, 10)-(150, 20), , B
Printer.Line (150, 10)-(200, 20), , B
Printer.Line (200, 10)-(230, 20), , B
Printer.Line (230, 10)-(240, 20), G_TabCouleurDefaut(2), BF
Printer.Line (240, 10)-(270, 20), , B
Printer.Line (270, 10)-(280, 20), G_TabCouleurDefaut(5), BF

'3eme Ligne
Printer.Line (0, 20)-(50, 30), , B
Printer.Line (50, 20)-(100, 30), , B
Printer.Line (100, 20)-(150, 30), , B
Printer.Line (150, 20)-(200, 30), , B
Printer.Line (200, 20)-(230, 30), , B
Printer.Line (230, 20)-(240, 30), G_TabCouleurDefaut(3), BF
Printer.Line (240, 20)-(270, 30), , B
Printer.Line (270, 20)-(280, 30), , B

'on renseigne le text :
With Printer
''''''''''''''''''''''''''''''''''''''''''1ere colonne'''''''''''''''''''''''''''''
'Nom Machine
.FontName = "Arial"
.FontSize = 10
.CurrentX = 2
.CurrentY = 2
Printer.Print "U101"

'Nom Operateur
.FontName = "Arial"
.FontSize = 10
.CurrentX = 2
.CurrentY = 12
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Opérateur : "
.CurrentX = 27
.CurrentY = 12
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_NomOperateur
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False

'Date
.FontName = "Arial"
.FontSize = 10
.CurrentX = 2
.CurrentY = 22
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Date : "
.CurrentX = 27
.CurrentY = 22
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_Date
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False
''''''''''''''''''''''''''''''''''''''''''2eme colonne'''''''''''''''''''''''''''''
'Plateau
.FontName = "Arial"
.FontSize = 10
.CurrentX = 52
.CurrentY = 2
Printer.Print "Plateau"

'FCI
.FontName = "Arial"
.FontSize = 10
.CurrentX = 52
.CurrentY = 12
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Four / Coulée / Indice :"
.CurrentX = 102
.CurrentY = 12
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_NumFour & " / " & G_NumCoulee & " / " & G_Indice
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False

'Alliage
.FontName = "Arial"
.FontSize = 10
.CurrentX = 52
.CurrentY = 22
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Alliage : "
.CurrentX = 77
.CurrentY = 22
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_Alliage
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False

''''''''''''''''''''''''''''''''''''''''''3eme colonne'''''''''''''''''''''''''''''
'Format
.FontName = "Arial"
.FontSize = 10
.CurrentX = 102
.CurrentY = 2
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Format : "
.CurrentX = 127
.CurrentY = 2
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_Format
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False
    
'Qualite
.FontName = "Arial"
.FontSize = 10
.CurrentX = 102
.CurrentY = 22
    Printer.FontItalic = False
    Printer.FontUnderline = True
    Printer.FontBold = True
Printer.Print "Qualité : "
.CurrentX = 127
.CurrentY = 22
    Printer.FontItalic = True
    Printer.FontUnderline = False
    Printer.FontBold = False
Printer.Print G_Qualite
    Printer.FontItalic = False
    Printer.FontUnderline = False
    Printer.FontBold = False

A voir également

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.