We help IT Professionals succeed at work.
Get Started

How auto export and how auto print - no viewing?

EYoung
EYoung asked
on
2,802 Views
Last Modified: 2008-01-09
I have written many VB6 applications that use Crystal Reports to display reports on the screen and allow the users to do whatever they want with the reports, i.e. view, print, export, etc.

Now the users of the applications are asking for two new features.  To automatically export the report to an Adobe Acrobat file or to automatically print the report to the default printer.  In either case the user does not want to have the report shown on the screen.  Just do the export or do the print, no viewing on the screen.

So I have created in VB6 some options that the users can click to select their choice, i.e. Send (export to Adobe, no viewing on screen), View (display report on screen) or Print (print to the printer, no viewing on screen.)

The Viewing code works just fine.  However, I can't figure out how to "automatically" export to Adobe Acrobat or "automatically" print to the printer without first showing the CRViewer9 control on the screen.

Specifically I want to do the following:

Send - Not show the report in CRViewer, just export automatically to an Adobe Acrobat file in a predefined folder, i.e. "C:\Temp\" without any prompts.

View - Works just fine.

Print - Not show the report in CRViewer, just print automatically to the default printer without any prompts.

Below is the code I have been using in the VB6 form that shows the report:

*******************************************************
Option Explicit

Dim Report As dsrSWR

Private Sub CRViewer92_PrintButtonClicked(UseDefault As Boolean)
    UseDefault = False
    Report.PrinterSetup (hWnd)
    Report.PaperOrientation = crPortrait
    'Report.PaperOrientation = crLandscape
    On Error GoTo Cancel:
    Report.PrintOut True

Cancel:
    Exit Sub
End Sub

Private Sub Form_Activate()
    Set Report = New dsrSWR

    Report.EnableParameterPrompting = False

    Report.ParameterFields(1).AddCurrentValue mSWR_Date
    Report.ParameterFields(2).AddCurrentValue mEmployee_mKey
    Report.ParameterFields(3).AddCurrentValue mFilled_or_Blank_Parm
    Report.ParameterFields(4).AddCurrentValue mQuantity_Parm
    Report.ParameterFields(5).AddCurrentValue mDefault_User_Name

    Select Case mSend_View_or_Print_Parm
        Case "S"
            Unload Me
        Case "V"
            Screen.MousePointer = vbHourglass
            CRViewer92.ReportSource = Report
            CRViewer92.DisplayTabs = False
            CRViewer92.DisplayToolbar = True
            CRViewer92.EnableGroupTree = False
            CRViewer92.EnableExportButton = True
            CRViewer92.ViewReport
            CRViewer92.Zoom (100)
            Screen.MousePointer = vbDefault
        Case "P"
            Screen.MousePointer = vbHourglass
            CRViewer92.ReportSource = Report
            CRViewer92.DisplayTabs = False
            CRViewer92.DisplayToolbar = True
            CRViewer92.EnableGroupTree = False
            CRViewer92.EnableExportButton = True
            CRViewer92.ViewReport
            CRViewer92_PrintButtonClicked (True)
            CRViewer92.Zoom (100)
            Screen.MousePointer = vbDefault
    End Select
End Sub

Private Sub Form_Resize()
    CRViewer92.Top = 0
    CRViewer92.Left = 0
    CRViewer92.Height = ScaleHeight
    CRViewer92.Width = ScaleWidth
End Sub
*******************************************************

Thanks for the help.
Comment
Watch Question
Senior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 18 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE