Imprimer une msflexgrid

Contenu du snippet

Procédure pour imprimer une grille msflexgrid avec sauts de page.

Source / Exemple :


Private Sub Imprimer()
On Error Resume Next
Dim NbLigne As Long
Dim Y As Double
Dim X As Double
Dim I As Long
Dim j As Integer
Dim Txt As Variant
Dim NbPages As Integer
Dim Rep As String
Dim NumPage As Integer
'grille=msflexgrid'
Printer.ScaleMode = 7
Printer.ScaleHeight = 29.7
Printer.ScaleWidth = 21
Printer.Font = "arial"
NbLigne = Me.Grille.Rows
NbPages = Int((NbLigne / 32) + 1)
Rep = InputBox("Préparez votre imprimante pour environ " & NbPages & " pages.", Vapi_Nomprog, "OUI")
If Rep <> "oui" Then
Exit Sub
End If
Y = 1
NumPage = 1
For I = 0 To Me.Grille.Rows
Y = Y + 0.4
'position des colonnes'
Printer.CurrentX = 1: Printer.CurrentY = Y: Printer.Print Me.Grille.TextMatrix(I, 1)
Printer.CurrentX = 8: Printer.CurrentY = Y: Printer.Print Me.Grille.TextMatrix(I, 2)
Printer.CurrentX = 11: Printer.CurrentY = Y: Printer.Print Me.Grille.TextMatrix(I, 3)
Printer.CurrentX = 14: Printer.CurrentY = Y: Printer.Print Me.Grille.TextMatrix(I, 4)
Printer.CurrentX = 17: Printer.CurrentY = Y: Printer.Print Me.Grille.TextMatrix(I, 5)
If I > 1 Then
Y = Y + 0.3
For j = 1 To 17
Printer.CurrentY = Y: Printer.CurrentX = j: Printer.Print "_________";
Next j
End If
If Y > 27 Then
Printer.CurrentX = 1: Printer.CurrentY = 28: Printer.Print "Page " & NumPage
Y = 1
NumPage = NumPage + 1
Printer.EndDoc
Y = 1
End If
Next I
Printer.CurrentX = 1: Printer.CurrentY = 28: Printer.Print "Fin/Page " & NumPage
Printer.EndDoc
End Sub

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.