Results 1 to 5 of 5

Thread: Set max lines to print ??

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    6

    Set max lines to print ??

    Hi..I have problem with printing function in vb..

    I have a program which will display data taken from the database and put into a flexgrid. Then, when user want to print it, they just choose which column to print..

    Currently, the papersize set to the printer is Letter type. However, the user usually use A4 size paper to print instead of Letter type paper (I dunno why they don't want to use Letter paper ) and make the bottom line of the text blurred or half printed..

    my question :
    is there any way i can set the maximum line to print? and when it reached the max line, it will automatically go to the next page?? this is because the bottom line shud have at least 1 inch space..

    this is the portion of my code :
    (i have to use the printDlg function because the common dialog box just cannot work correctly in my program)
    VB Code:
    1. Me.rtbPrintInfo.SelFontName = "Courier New"
    2. 'Me.rtbPrintInfo.SelFontSize = 7
    3. Me.rtbPrintInfo.LoadFile fileName, rtfText
    4.  
    5. Dim NumCopies As String
    6. Dim Index As Integer
    7. Dim printDlg As PrinterDlg
    8. Dim NewPrinterName As String
    9. Dim objPrinter As printer
    10. Dim strsetting As String
    11.  
    12. Set printDlg = New PrinterDlg
    13.  
    14. printDlg.printerName = printer.DeviceName
    15. printDlg.DriverName = printer.DriverName
    16. printDlg.Port = printer.Port
    17. printDlg.PaperBin = printer.PaperBin
    18. printDlg.PaperSize = printer.PaperSize
    Last edited by Hack; Mar 6th, 2006 at 07:54 AM. Reason: Added [vbcode] [/vbcode] tags and for more clarity.

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Set max lines to print ??

    You must check for the lines drawn so far and then use
    printer.NewPage

    to make a new page

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    6

    Re: Set max lines to print ??

    thanks for the quick reply..
    but, i dunno how to get the lines drawn so far..can u explain more?

    below is the current codes for printing..thanks!
    VB Code:
    1. Me.rtbPrintInfo.SelFontName = "Courier New"
    2. 'Me.rtbPrintInfo.SelFontSize = 7
    3. Me.rtbPrintInfo.LoadFile fileName, rtfText
    4.  
    5. Dim NumCopies As String
    6. Dim Index As Integer
    7. Dim printDlg As PrinterDlg
    8. Dim NewPrinterName As String
    9. Dim objPrinter As printer
    10. Dim strsetting As String
    11.  
    12. Set printDlg = New PrinterDlg
    13.  
    14. printDlg.printerName = printer.DeviceName
    15. printDlg.DriverName = printer.DriverName
    16. printDlg.Port = printer.Port
    17. printDlg.PaperBin = printer.PaperBin
    18. printDlg.PaperSize = printer.PaperSize
    19.  
    20. ' Set the flags for the PrinterDlg object using the same flags as in the
    21. ' common dialog control. The structure starts with VBPrinterConstants.
    22. printDlg.flags = VBPrinterConstants.cdlPDNoSelection _
    23.                  Or VBPrinterConstants.cdlPDNoPageNums _
    24.                  Or VBPrinterConstants.cdlPDReturnDC
    25. printer.TrackDefault = False
    26. Index = 0
    27. For Each objPrinter In Printers
    28.     Index = Index + 1
    29. Next
    30.  
    31. If Index > 1 Then
    32.     printDlg.CancelError = True
    33.     On Error GoTo ErrHandler
    34.     If Not printDlg.ShowPrinter(Me.hwnd) Then
    35.         Exit Sub
    36.     End If
    37.     NewPrinterName = UCase$(printDlg.printerName)
    38.     If printer.DeviceName <> NewPrinterName Then
    39.         For Each objPrinter In Printers
    40.            If UCase$(objPrinter.DeviceName) = NewPrinterName Then
    41.                 Set printer = objPrinter
    42.            End If
    43.         Next
    44.     End If
    45.     NumCopies = printDlg.Copies
    46.     printer.Orientation = 2
    47.     If NumCopies > 0 Then
    48.         For i = 1 To NumCopies
    49.             Me.rtbPrintInfo.SelPrint printer.hdc
    50.         Next i
    51.     End If
    52. ElseIf Index = 1 Then
    53.     printer.Orientation = 2
    54.     Me.rtbPrintInfo.SelPrint printer.hdc
    55. ElseIf Index = 0 Then
    56.     mhMain_triggerTime (True)
    57.     MsgBox "Printer not installed!"
    58.     mhMain_triggerTime
    59.     Exit Sub
    60. End If
    Last edited by Hack; Mar 6th, 2006 at 07:54 AM. Reason: Added [vbcode] [/vbcode] tags and for more clarity.

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Set max lines to print ??

    Ahh. I thought you meant using Printer.Print

    In that case I have no idea sorry.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    6

    Re: Set max lines to print ??

    i see..anyway, thanks Andrew G
    can anyone help me? thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width