Results 1 to 3 of 3

Thread: Export Crystal Report in DOC format

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    Export Crystal Report in DOC format

    Hi Friends,

    I've used Access, VB6 and Crystal Report8.5. Now My reports are working fine. But Now I want to add one more facility. I want to export my report in the DOC format. I've used crystal report control (ocx) file and following code to display reports which are stored in "reports" folder of my software.

    VB Code:
    1. With crRegistration
    2.         .Connect = strConn
    3.         .ReportFileName = App.Path & "\reports\RegistrationLetter.rpt"
    4.         .WindowTitle = "Registration Conmfirmation Letter"
    5.         .SelectionFormula = "{tblStudent.studentid}='" & sStudentId & "'"
    6.         .WindowState = crptMaximized
    7.         .Destination = crptToPrinter
    8.         .printReport
    9.         .Action = 1
    10.     End With

    Plz help me to write a code which saves this report in the folder (folder name has to be entered by user.) . I am not using crystal report viewer control just crystal report activex control. plz help me.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    Re: Export Crystal Report in DOC format

    Hi tried as follows. It works fine but it is displaying all the records. But I want to display only selected one.

    VB Code:
    1. Dim rs As New ADODB.Recordset
    2.     Dim crystal As CRAXDDRT.Application
    3.     Dim Report As CRAXDDRT.Report
    4.    
    5.     rs.CursorLocation = adUseClient
    6.     rs.Open "select * from tblStudent where studentid='S15'", cn
    7.    
    8.     Set crystal = New CRAXDDRT.Application
    9.    
    10.     Set Report = crystal.OpenReport("d:\damini\school\reports\RegistrationLetter.rpt")
    11.     Report.DiscardSavedData
    12.     Report.Database.SetDataSource rs
    13.  
    14.     Report.ExportOptions.FormatType = crEFTWordForWindows
    15.     Report.ExportOptions.DiskFileName = "c:\test.doc"
    16.     Report.ExportOptions.DestinationType = crEDTDiskFile
    17.     Report.Export False
    18.     MsgBox "Exported"

    so instread of exporting only one record it is exporting all records. also i tried same to view in crystal report viewer control but it is showing for all records and not of only one id.

    plz reply ASAP.

    thanks in advance

  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Laredo, TX.
    Posts
    29

    Lightbulb Re: Export Crystal Report in DOC format

    In my applications this code works great:

    VB Code:
    1. Private Sub genera_rtf()
    2.     CrystalReport1.ReportFileName = "f:\casachapa\billcasachapa.rpt"
    3.     CrystalReport1.SelectionFormula = "{BLGeneral.BLnumero}=" & Trim(FormSalidas.Text1.Text)
    4.     CrystalReport1.Destination = crptToFile
    5.     CrystalReport1.PrintFileType = crptRTF
    6.     CrystalReport1.PrintFileName = "c:\casachapa\casa.doc"
    7.     CrystalReport1.Action = 1
    8. End Sub
    VB6 / SQL Server Express 2005.

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