Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Printer options

I wasn't sure whether to put this under Crystal or VB, so if you think it is more of a VB question please say and i'll re-post it there or request it be moved....


We are using the crystal viewer in a VB and VBA environment. Our report appears within the crystal viewer without problem. However, we have need to print the report to different printers AND to specify the printer tray.
However, when you click the print icon, Crystal picks up the default printer and not only does not allow you to select a different printer but also does not allow you to select a tray for the printer in question.

Is there away to get the printer options box to display instead of directly printing using all of the defaults?

Any help would be much appreciated.
0
kinton
Asked:
kinton
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
Brian CroweDatabase AdministratorCommented:
If you are printing through an app then don't allow the crystal viewer to display the print button.  Instead provide your own printing functionality.  I've done this exact thing but in VB.Net so I'm hoping it translates.  Display your own printdialog and then copy the printersettings from the printdialog to your reportdocument's printsettings.  You can also override the papersource (there may be some issues if your printer is an HP but that's a separate discussion)
0
 
mlmccCommented:
I have a limited printer options form I built and code to use it if interested.

mlmcc
0
 
vidruCommented:
The CRViewer has a PrintButtonClicked event.  You can use the Report object's PrinterSetup method to invoke a dialog that allows the user to pick a printer/tray, etc.  This might be overkill, but this is a common example of what I put in the PrintButtonClicked event:

Private Sub Viewer_PrintButtonClicked(UseDefault As Boolean)
    'Get the report's current orientation and paper size
    'CRPaperOrientation and CRPaperSize are Enumerated type _
        members of the CRAXDRT library
    Dim cOrientation As CRPaperOrientation
    Dim cSize As CRPaperSize
    cOrientation = crxRpt.PaperOrientation
    cSize = crxRpt.PaperSize
   
    'Call the Printer Setup dialog
    crxRpt.PrinterSetupEx Me.hwnd

    'Loop through the Printers collection to ensure the correct _
        printer gets set for the report
    Dim p As Printer
    For Each p In Printers
        If p.DeviceName = crxRpt.PrinterName Then
            crxRpt.SelectPrinter p.DriverName, p.DeviceName, p.Port
            Exit For
        End If
    Next p

    'Reset the report's PaperOrientation and PaperSize properties _
        to override the "new" printer's defaults
    crxRpt.PaperOrientation = cOrientation
    crxRpt.PaperSize = cSize
End Sub

-dave
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
kintonAuthor Commented:
Thanks for your replies - got sidetracked with something else, sorry!

I wouldnt mind having a look at your code mlmcc - even if I don't use it in this instance it may be handy for some other printing issues we'll soon be attempting to implement.


Thanks for your code vidru.  I'm going to give this a go - hopefully soon, once i've got a report im doing out of the way.  I wont forget the post, it just might take me a few days.

0
 
kintonAuthor Commented:
One quick question, what is crxRpt defined as?
0
 
Brian CroweDatabase AdministratorCommented:
ReportDocument
0
 
vidruCommented:
That's the report object.  In the General Declarations section of the form module where the report will be printed, I usually declare the Application and Report objects there:

Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report

Private Sub Form_Load()
  Set crxRpt = crxApp.OpenReport("Report1.rpt")

  etc.......

-dave
0
 
mlmccCommented:
Look here for - form_printer_setup.frm

http://groups.msn.com/McCrackenUNO/files.msnw?fc_p=%2FExperts%20Exchange%20Files&fc_a=0

You may have to create an msn passport.  If you can't get to it let me know and I'll try to post it elsewhere.

mlmcc
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now