Impression en couleur avec printer

asgarth Messages postés 6 Date d'inscription mercredi 14 mai 2003 Statut Membre Dernière intervention 1 décembre 2003 - 7 juin 2003 à 00:02
cs_rene38 Messages postés 1858 Date d'inscription samedi 29 juin 2002 Statut Membre Dernière intervention 17 octobre 2013 - 7 juin 2003 à 11:15
Bonjour
Je veux imprimer un fichier text en noir avec certains mots en rouge!
quelles propriétés utiliser avec l'objet Printer ou Font?
qqch dans le genre :
Printer.FontColor=VBRed
Faaut-il passer par le mode graphique?

Un bout de code ou un lien me serait utile.
merci

2 réponses

nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 37
7 juin 2003 à 02:29
un ptit bout de programme à adapter à ta situation gere pas les couleurs mais d'autres controles mais pas tous.
Il faut avoir des conventions de nommage ..

Private Sub print_control(printer As printer, ByVal control As Object)
If (Left(control.Name, 4) = "Line") Then
printer.Line (control.X1, control.Y1)-(control.X2, control.Y2)
ElseIf (Left(control.Name, 5) = "Image") Then
'printer.Line (control.X1, control.Y1)-(control.X2, control.Y2)
Dim stdPict As New StdPicture
Set stdPict = LoadPicture(App.Path & "\myphoto.jpg")
printer.PaintPicture stdPict, control.Left, control.Top, control.Width, control.Height
Else

Select Case control.Alignment
Case vbCenter

printer.CurrentX = control.Left + control.Width / 2 - printer.TextWidth(control.Caption) \ 2
Case vbLeftJustify
printer.CurrentX = control.Left
Case vbRightJustify
printer.CurrentX = control.Left + control.Width - printer.TextWidth(control.Caption)
End Select

printer.CurrentY = control.Top

printer.FontBold = control.Font.Bold
printer.Font.Name = control.Font.Name
printer.Font.Size = control.Font.Size

If (LCase(Left(control.Name, 2) = "lb")) Then
printer.Print control.Caption
Else
MsgBox control.Name
End If
End If
End Sub
0
cs_rene38 Messages postés 1858 Date d'inscription samedi 29 juin 2002 Statut Membre Dernière intervention 17 octobre 2013 11
7 juin 2003 à 11:15
Bonjour

Printer.Print "Noir ";
Printer.ForeColor = vbRed
Printer.Print "Rouge"
Printer.EndDoc


écrira :

Noir Rouge
0
Rejoignez-nous