CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Location
    Jordan
    Posts
    30

    Open printer dialog in runtime mode in VB6

    Hay,
    when i open report from visual basic 6 using viewer its give me only printer icon which only print direct to deafult printer without any option to choose another printer.
    How i can choose which printer i want in runtime in VB6

  2. #2
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651

    Re: Open printer dialog in runtime mode in VB6

    If found this:

    Code:
    Report.PrinterSetup 0
    Report.PrintOut
    But for me it was easier to create my own Printer Selection form. I added a combobox for the Printer (filling it by looping through the Printers Collection), option buttons for All Pages or a specific page range, and a spinner for number of copies. I also added properties to the SelectPrinter Form to hold the data. Once the user picks the options and clicks 'Print', VB send the data to Crystal's .Printout.

    Code:
    Private Sub CRViewer_PrintButtonClicked(useDefault As Boolean)
        
        Dim cOrientation    As CRPaperOrientation
        Dim cSize           As CRPaperSize
        
        useDefault = False
        
        'Capture the original Orientation and Paper Size,
        '       SelectPrinter resets Landscape to Portrait
        cOrientation = Report.PaperOrientation
        cSize = Report.PaperSize
            
        'Reset Form and all data by calling the NewData function on the SelectPrinter Form
        frmSelectPrinter.NewData
                
        'Set Max Number of Pages
        frmSelectPrinter.MaxPages = Report.PrintingStatus.NumberOfPages
        
        'Show Form and wait for User
        frmSelectPrinter.Show vbModal
        
        If Len(frmSelectPrinter.DeviceName) > 0 Then
            'If a device is selected, print report
            Report.SelectPrinter frmSelectPrinter.DriverName, _
                                    frmSelectPrinter.DeviceName, frmSelectPrinter.Port
            
            'Set the Orientation and Paper Size to the original,
            '       SelectPrinter resets Landscape to Portrait
            Report.PaperOrientation = cOrientation
            Report.PaperSize = cSize
                    
            Report.PrintOut False, frmSelectPrinter.Copies, , _
                                    frmSelectPrinter.FromPage, frmSelectPrinter.ToPage
        
            
        End If
    
    End Sub
    I'd rather be wakeboarding...

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

Featured