Go Premium for a chance to win a PS4. Enter to Win

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

Select a printer from crystal viewer

I'm trying to make it possible to select a printer when you press the printer button when using crviewer.  I Used this  code from crystal decisions:
                   Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)

                    UseDefault = False
                    On Error GoTo Cancel:
                    CommonDialog1.CancelError = True
                    CommonDialog1.ShowPrinter
                    MyRep.PrintOut False  
                    Exit Sub
                    Cancel:
                    MsgBox "Printing cancelled"
                    Exit Sub
                    End Sub
Everything works fine until after I've select my printer and click print.  At this point i get the "Printing cancelled" message box and nothing works. Any help would be greatly appreciated.
0
asmit8
Asked:
asmit8
3 Solutions
 
asmit8Author Commented:
Is there a reference or component i'm missing or something?
0
 
kathmacmahonCommented:
I had written similar code that worked up until Windows 2000 was released.  I determined that no matter the orientation selected on the print dialog, crystal wouldn't catch it.  I don't know if that's still an issue but you should probably test that.  Your users may try to make changes to their printer settings in the common dialog that might not change the way the report prints.

I think what you need to do is change your MSGBox to output the error that is occuring, because it might not be Printing Cancelled.  I ran the same code in their sample project and it worked.

Ultimately, I ended up placing the viewer on a form and disabling most of the inherit toolbar items and creating one of my own that allows the user to select either 'print' or 'print setup'.  There's a sample below that shows all the various ways to affect printer settings.

http://support.crystaldecisions.com/communityCS/FilesAndUpdates/printersettings.zip.asp
0
 
mlmccCommented:
It may be this line that is causing the problem of getting the PRINT CANCELLED displayed.

     CommonDialog1.CancelError = True

mlmcc
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.

 
EwaldLCommented:
currently i can't see the link between your common dialog and the report. try hardcoding the values first such as
crReport.SelectPrinter "drivername", "printername", "port"
from (http://support.crystaldecisions.com/library/kbase/articles/c2003560.asp)

if you are in cr 9, then also set the paper orientation
http://support.crystaldecisions.com/library/kbase/articles/c2012124.asp
0
 
asmit8Author Commented:
I figured it out...thanks for all your help!
0
 
mlmccCommented:
And the answer is?

mlmcc
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now