How to Print the content of a MSHFlexGrid
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 'Controls - How to Print the content of a MSHFlexGrid Option Explicit Dim BeginPage, EndPage, NumCopies, Orientation, I Dim curI As Long, curiX As Long Public Sub PrintContent(Valid As Boolean) On Error Resume Next CommonDialog1.CancelError = True On Error GoTo ErrHandler CommonDialog1.ShowPrinter BeginPage = CommonDialog1.FromPage EndPage = CommonDialog1.ToPage NumCopies = CommonDialog1.Copies Orientation = CommonDialog1.Orientation 'How many copies to be printed For I = 1 To NumCopies Printer.FontSize = 8 Printer.ScaleMode = 1 curi = 200 curix = 0 contor = CLng((MSHFlexGrid1.Cols(0)) - 1) J = Printer.CurrentY For X = 1 To m If X <> 0 And X Mod 60 = 0 Then curi = 200 Printer.NewPage Else curi = curi + 240 End If For J = 0 To contor curix = MSHFlexGrid1.ColPos(J) Printer.CurrentY = curi Printer.CurrentX = curix Printer.FontBold = False Printer.Print MSHFlexGrid1.TextMatrix(X, J) Next curix = 0 Next Printer.FontItalic = True Printer.Print "Total " & m & " records" Printer.EndDoc Next Exit Function ErrHandler: 'User pressed Cancel button. Exit Function End Function |