?
Solved

Exporting Crystal eports through VB6 Crystal OCX

Posted on 2002-05-16
14
Medium Priority
?
1,344 Views
Last Modified: 2007-11-27
I want to export a Crystal 8.5 report to RTF format. Whenever I do this, I am prompted as to whether to export all the pages or to specify specific pages. Is there any way to get rid of this and default the option to All Pages?
0
Comment
Question by:zoobird
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 7014196
How are you doing the export?

If it is from VB please show the code.

mlmcc
0
 
LVL 1

Expert Comment

by:Brighton
ID: 7014217
If you are using VB then try prior to your export.

DisplayProgressDialog = False
0
 

Author Comment

by:zoobird
ID: 7014585
is DisplayProgressDialog a property of the Crystal Report object?
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 1

Expert Comment

by:Brighton
ID: 7014656
Yes
 Here is a little VB program on how I use it.


Dim crxApplication As New CRAXDRT.Application

Private Report As CRAXDRT.Report

Private Sub Form_Load()

    ' This program expects at lest 3 parameters to be passed to it
    ' and the program first parses the command line into a ParameterArray
    '
    ' ParameterArray(1)   = Report to run
    ' ParameterArray(2)   = Output destination
    ' ParameterArray(3)   = What format is the output saved as
    ' ParameterArray(4+N) = Parameters that are passed to the crystal
    '                       report in the same order they are listed
    '                       in the report.
    '
    ' The program them sets any parameters the are passed in to it and places
    ' these values in the parameters that are in the report.
    '
   

    On Error GoTo ErrorHandle
    Dim linenbr As Integer
   
    Dim ParameterArray() As String
    Dim OutFile          As String      'ParameterArray(2)
    Dim OutputFormat     As Integer     '0 = No Format
                                        '1 = Crystal Report Format
                                        '8 = Text
                                        '31 = PDF
   
   
    Dim RC As Integer
    Dim Pcnt As Integer
    '
    ' Fill the array with the command line passed in
    ' using the comma as a deliminator between fields.
    '
    RC = FillArray(Command, ",", ParameterArray())
         
 
    Set crxApplication = New CRAXDRT.Application
   
    Dim crxParameterField As CRAXDRT.ParameterFieldDefinition
    Dim crxparameterFields As CRAXDRT.ParameterFieldDefinitions
   
    '
    ' The first parameter passed in is the name of the
    ' report to run
    '
   
    Set Report = crxApplication.OpenReport(Trim(ParameterArray(1)))
    Report.DiscardSavedData
   
    '
    ' The second parameter is the location where the
    ' the output file is to go
    '
    OutFile = Trim(ParameterArray(2))
   
    Pcnt = Report.ParameterFields.Count
    If Pcnt > 0 Then
        Set crxParameterField = Report.ParameterFields.Item(1)
    End If
   
 
    '
    ' Log on to the database
    '
    For i = 1 To Report.Database.Tables.Count
        Report.Database.Tables(i).SetLogOnInfo "", "", "<<Use Integrated Security>>", ""
    Next i
   
    If Pcnt > 0 Then
        crxParameterField.EnableMultipleValues = True
        Call crxParameterField.ClearCurrentValueAndRange
    End If

    '
    ' Read each parameter from the report and populate
    ' them in the same order they are read in from
    ' the command line.
    '
    Dim crnull As Variant
    For Each crxParameterField In Report.ParameterFields
        crxParameterField.AddCurrentValue crnull
    Next
   
    Pcnt = Report.ParameterFields.Count
    If Pcnt > 0 Then
        For x = 1 To Pcnt
          If ParameterArray(x + 3) = "" Then
             Report.ParameterFields(x).AddCurrentValue crnull
          ElseIf Report.ParameterFields(x).ValueType = crNumberField Then
             Report.ParameterFields(x).AddCurrentValue CDbl(Trim(ParameterArray(x + 3)))
          Else
             Report.ParameterFields(x).AddCurrentValue CStr(Trim(ParameterArray(x + 3)))
          End If
        Next x
    End If
   
    Select Case Trim(CInt(ParameterArray(3)))
     Case Is = 0
      OutputFormat = 0  ' No Format
     
     Case Is = 1
      OutputFormat = 1  ' Crystal Report Format
     
     Case Is = 8
      OutputFormat = 8  ' Text
     
     Case Is = 31
      OutputFormat = 31 ' crEFTPortableDocFormat (PDF)
     
    End Select
   
    If OutputFormat = 0 Then
        RptName.Caption = Trim(ParameterArray(1))
        Form2.Show
    Else
   
        Report.DisplayProgressDialog = False
        Report.ExportOptions.DestinationType = crEDTDiskFile
        Report.ExportOptions.FormatType = OutputFormat
        Report.ExportOptions.DiskFileName = OutFile
        Report.Export False
    End If

    Err.Number = 0
    Unload ExecCR
    Exit Sub
   
   
ErrorHandle:
   
    Label1.Caption = linenbr
    Label2.Caption = Err.Number
    Label3.Caption = Err.Description
    Debug.Print Err.Number
   
    Err.Number = 1
    Unload ExecCR
   
   
End Sub


Function FillArray(CommandLineIn As String, Delimiter As String, aValues() As String) As Integer

     Dim ArrayCount As Integer
     Dim CurrentPosInArray As Integer
     Dim LenghtOfVariable As Integer
     Dim StringLength As Integer

     ArrayCount = 1
     CurrentPosInArray = 1
     LenghtOfVariable = 1

     StringLength = Len(CommandLineIn)
     Do
           ReDim Preserve aValues(1 To ArrayCount) As String

           StringLength = (InStr(CurrentPosInArray, CommandLineIn, Delimiter) - CurrentPosInArray)

           If StringLength < 0 Then

                 aValues(ArrayCount) = Right$(CommandLineIn, (Len(CommandLineIn) - (LenghtOfVariable - 1)))

                 Exit Do

           Else

                  aValues(ArrayCount) = Mid$(CommandLineIn, CurrentPosInArray, StringLength)

           End If

           LenghtOfVariable = LenghtOfVariable + (Len(aValues(ArrayCount)) + Len(Delimiter))
           CurrentPosInArray = LenghtOfVariable
           ArrayCount = ArrayCount + 1

     Loop
     If ArrayCount = 2 Then
        ArrayCount = 3
        ReDim Preserve aValues(1 To ArrayCount) As String
        aValues(3) = 8
     
     End If

     FillArray = UBound(aValues)

End Function



You would need to add to the case statement the condition to look for RTF output if you wanted RichText output.

     Case Is = 4
      OutputFormat = 4 ' crEFTRichText (RTF)
     


0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7016341
is DisplayProgressDialog a property of the Crystal Report object?

yes

CR1.DisplayProgressDialog = false

mlmcc
0
 

Author Comment

by:zoobird
ID: 7017115
I don't have that option in my crystal report object.
0
 
LVL 1

Expert Comment

by:kzbera
ID: 7018055
Hi I used similar thing for exporting to pdf format where it exported all the report.
here is the code..
try similarly to export to RTF
let me know whether it worked or not

********
Private Sub Command6_Click()
Dim CRPApplication As CRPEAuto.Application
Dim CRPReport As CRPEAuto.report
Dim db As CRPEAuto.Database
Dim dbT As CRPEAuto.DatabaseTables
Dim i As Integer

Set CRPApplication = CreateObject("Crystal.CRPE.Application")

 Set CRPReport = CRPApplication.OpenReport(app.Path & "\Magic Page.rpt")
'CRPApplication.LogOnServer "c:\winnt\system32\crpe32.dll", "XXX", "xxx", "yyy", "zzz"

Set CRPParameterFieldDefs = CRPReport.ParameterFields

For i = 1 To CRPParameterFieldDefs.Count

     Set CRPParameterFieldDef = CRPParameterFieldDefs.Item(i)
     
     'MsgBox CRPParameterFieldDef.Name

Next i

Set db = CRPReport.Database
Set dbT = db.Tables
 dbT.Item(1).SetLogOnInfo "XXX", "xxx", "yyy", "zzz"
CRPReport.Preview

        Dim strFileName, str As String
        Dim pos As Integer
        pos = InStr(1, (app.Path & "\Magic Page.rpt"), ".", vbTextCompare)
        str = Mid(app.Path & "\Magic Page.rpt", 1, pos - 1)
        strFileName = str & ".pdf"
'        CRPReport.ExportOptions.Reset
'        CRPReport.ExportOptions.DestinationType crEDTDiskFile
'        CRPReport.ExportOptions.FormatType crEFTPortableDocFormat
'        CRPReport.ExportOptions.DiskFileName strFileName ' save as
'        CRPReport.ExportOptions.PDFExportAllPages True
'         CRPReport.Export False ' overwrite and skip dialog box
'        MsgBox "exported"
   
End Sub
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7018277
DisplayProgressDialog
I don't have that option in my crystal report object

There are several methods (ActiveX, RDC, OCX, Report Engine, Automation Engine)  Each has its own set of properties.  To help solve your problem we need to see the code you are using, the declaraion of the CR objects, and the CR references you are using.

mlmcc
0
 

Author Comment

by:zoobird
ID: 7028765
Form1.CrystalReport1.PrintFileType = crptRTF
Form1.CrystalReport1.PrintFileName = "C:\report.rtf"

Form1.CrystalReport1.ReportFileName = "C:\report.rpt"
Form1.CrystalReport1.Connect = "DSN=reportdsn"
Form1.CrystalReport1.DialogParentHandle = False

lReturnCode = Form1.CrystalReport1.PrintReport


Unfortunately, when I do Form1.CrystalReport1.DisplayProgressDialog, I get an error because it doesn't seem to be a property of the CrystalReport1 object.

0
 

Author Comment

by:zoobird
ID: 7028780
I found a similar property called ProgressDialog. However, that isn't my problem. My problem is when exporting the report to RTF format, it prompts for whether to print All pages or specific pages. I really don't care about the progress dialog box because it automatically closes. I don't want any user interaction with the program I'm writing.

I will increase points if necessary.
0
 

Author Comment

by:zoobird
ID: 7030104
kzbera,

Do I need to make a reference to the CRPEAuto.Application? Which component should I reference to make it avaialble in my project?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7030940
Add the following line

Form1.CrystalReport1.Destination = crptToFile

replace
lReturnCode = Form1.CrystalReport1.PrintReport
 with

Form1.CrystalReport1.Action = 1

mlmcc
0
 

Author Comment

by:zoobird
ID: 7031110
Unfortunately, I'm still being prompted whether to export all pages or specific pages. It only happens with exporting to RTF format.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 225 total points
ID: 7031136
Try this (it is for the RDC but i wouldn't be surprised if the ActiveX control had comething similar)

Report.ExportOptions.RTFExportAllPages = True

http://support.crystaldecisions.com/library/kbase/articles/c2010169.asp

mlmcc


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question