je le programme sous vb mais l'affichage c'est sous Microsoft Office Document Imaging, mon code est le suivant:
Private Sub btImprimer_Click() 'connection a la base de donnees Set cnx = New ADODB.Connection cnx.Open "dsn=facturefondation" Set rs = New ADODB.Recordset 'creation de letat Dim ligne As String Dim X, Y As Integer, NbLigne As Long, NbPage As Long, i As Long Dim temp As Boolean 'On configure l'impression 'Unité de mesure en millimètres Printer.ScaleMode = vbMillimeters 'Format A4 Printer.PaperSize = vbPRPSA4 ' temp = False 'Orientation Portrait Printer.Orientation = vbPRORLandscape 'vbPRORPortrait Call EntetePage sql = "Select id,num_fact,montant_fact,date_etablissement," & _ "date_arrivee,date_echeance,type_fact,num_reference_fact,num_fournisseur,nom_fournisseur," & _ "observation_fact,comptedebit_fact,comptecredit_fact,montant_ht,cr_fact,actif From facture" & _ " where actif=" & 1 rs.Open sql, cnx ' XFixe = 20 - (297 - Printer.ScaleWidth) / 2 ' YMobile = 45 - (210 - Printer.ScaleHeight) / 2 NbLigne = rs.RecordCount NbPage = IIf(NbLigne Mod 16 > 0, NbLigne \ 16 + 1, NbLigne \ 16) 'place le curseur Y = 20 i = 1 While Not (rs.EOF) ' rs.MoveFirst ' For i = 0 To NbLigne - 1 ' If (temp = False) Then i = i + 1 Printer.CurrentX = 10 '20 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "Arial " Printer.Print rs.Fields("id").Value ' & " " & rs.Fields("num_fact").Value 'concatene le nom et le prenom Printer.CurrentX = 25 '100 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "code-39" Printer.Print rs.Fields("num_fact").Value ' "*" & rs.Fields("num_fact").Value & "*" 'en code 39 le signe de debut et de fin du code barre est * Printer.CurrentX = 50 '100 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "code-39" Printer.Print rs.Fields("montant_fact").Value Printer.CurrentX = 70 '100 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "code-39" Printer.Print rs.Fields("date_etablissement").Value Printer.CurrentX = 90 '100 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "code-39" Printer.Print rs.Fields("date_arrivee").Value Printer.CurrentX = 110 '100 Printer.CurrentY = Y Printer.FontSize = 10 Printer.FontName = "code-39" Printer.Print rs.Fields("date_echeance").Value
rs.MoveNext 'permet d'aller sur le champs suivant dans la table employé Y = Y + 12 'on réinitialise la position du curseur If i = 15 Then Printer.NewPage Call EntetePage Y = 20 i = 0 End If DoEvents ' rs.MoveNext ' Next i Wend Printer.EndDoc rs.Close
End Sub
cordialement
|