Subject: Export to Many files using VB6 and CR8.5
Posted By: PauloMongo Post Date: 10/20/2003 7:02:29 AM
I have a report that is grouped by client, on each GH1 an email address appears, I need to be able to export out of crystal reports to seperate files where a new GH starts and email to each client there specific report.

Does anybody know whether this is possible

Reply By: imran64 Reply Date: 10/28/2003 3:39:04 AM



'Option Explicit
Dim crxReport As CRAXDRT.Report
Dim crxApplication As New CRAXDRT.Application
Public X As Integer
'Public crxApplication As CRAXDRT. Object
'Public crxReport As Object
Public crxDatabase As CRAXDRT.Database
Public crxDatabaseTables As CRAXDRT.DatabaseTables
Public crxDatabaseTable As CRAXDRT.DatabaseTable
Public crxSections As CRAXDRT.Sections
Public crxSection As CRAXDRT.Section
Public crxSubreport As Object
Public crxSubreportObject As CRAXDRT.SubreportObject
Private Sub CmdClose_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Reporting
End Sub

Private Sub Reporting()
Me.Caption = "Report"
'ReportPath = "E:\worldcall inventory system\Crystal Reports\DailyCorporateRechargeTransfer.rpt"
'Screen.MousePointer = vbHourglass
Set crxReport = crxApplication.OpenReport(ReportPath)
crxReport.DiscardSavedData
CRViewer1.ReportSource = crxReport
CRViewer1.ViewReport
CRViewer1.Zoom 100
CRViewer1.EnableExportButton = True
CRViewer1.DisplayTabs = True
Command1_Click
'CRViewer1.CloseView 30
End Sub

Private Sub Form_Resize()
'crxReport.re
Set crxReport = crxApplication.OpenReport(ReportPath)
crxReport.DiscardSavedData
'CRViewer1.Refresh
With CRViewer1
    .Top = 0
    .Left = 0
    .Width = 11775 'Me.ScaleWidth
    .Height = 7215 'Me.ScaleHeight
End With

End Sub




''''''ACTUAL CODE START FROM THERE IF YOU HAVE TO EXPORT THE FILE>>>>>>>>
Private Sub Command1_Click()

Dim mReportDir, mExportDir, mReportName, mExportType As String
Dim mServerName, mdata, mUserId, mPassword As String


mReportDir = "E:\worldcall inventory system\Crystal Reports\"
mReportName = "FromToCorporateRechargeTransfer.rpt"
mExportDir = "E:\worldcall inventory system\Crystal Reports\"
mExportType = "xls"
mServerName = "dbcon"
mdata = "UserData"
mUserId = "administrator"
mPassword = "s"
  
   Dim strFile, strTemp, reportFile As String
  Dim count As Integer
  
   
  strFile = "FromToCorporateRecharge.rpt" 'Dir(mReportDir)
'-------------------------------------------------------------------

'Do
   reportFile = "oneFromToCorporateRecharge.rpt"
'-------------------------------------------------------------------

   Set crxReport = crxApplication.OpenReport(mReportDir & strFile)
   crxReport.DiscardSavedData

   Set crxDatabase = crxReport.Database

   Set crxDatabaseTables = crxDatabase.Tables

   count = 1
   For Each crxDatabaseTable In crxDatabaseTables
       crxDatabaseTable.SetLogOnInfo mServerName, mdata, mUserId, mPassword
       count = count + 1
   Next crxDatabaseTable


   Set crxSections = crxReport.Sections

   For Each crxSection In crxSections

       For X = 1 To crxSection.ReportObjects.count

  If crxSection.ReportObjects(X).Kind = crSubreportObject Then

   Set crxSubreportObject = crxSection.ReportObjects(X)
  Set crxSubreport = crxSubreportObject.OpenSubreport
  Set crxDatabase = crxSubreport.Database
  Set crxDatabaseTables = crxDatabase.Tables


  count = 0
  For Each crxDatabaseTable In crxDatabaseTables
       crxDatabaseTable.SetLogOnInfo mServerName, mdata, mUserId, mPassword
       count = count + 1
  Next crxDatabaseTable

 End If

 Next X

Next crxSection

   crxReport.ExportOptions.Reset
'----------------------------------------------------------------
   If (mExportType = "pdf") Or (mExportType = "PDF") Then
   crxReport.ExportOptions.FormatType = crEFTPortableDocFormat
   'crxReport.ExportOptions. = True
   End If

   If (mExportType = "doc") Or (mExportType = "DOC") Then
   crxReport.ExportOptions.FormatType = crEFTWordForWindows
   End If

   If (mExportType = "xls") Or (mExportType = "XLS") Then
   crxReport.ExportOptions.FormatType = crEFTExcel80
   End If

   If (mExportType = "txt") Or (mExportType = "TXT") Then
   crxReport.ExportOptions.FormatType = crEFTText
   End If

   If (mExportType = "csv") Or (mExportType = "CSV") Then
   crxReport.ExportOptions.FormatType = crEFTCommaSeparatedValues
   End If

   If (mExportType = "rtf") Or (mExportType = "RTF") Then
   crxReport.ExportOptions.FormatType = crEFTExactRichText
   End If
'------------------------------------------------------------------
   crxReport.ExportOptions.DestinationType = crEDTDiskFile

   crxReport.ExportOptions.DiskFileName = (mExportDir & reportFile & "." & mExportType)

   crxReport.ExportOptions.UseReportDateFormat = True

    crxReport.ExportOptions.UseReportNumberFormat = True

    crxReport.Export (False)
'-------------------------------------------------------------------
strTemp = strTemp & strFile

'strFile = Dir
'Loop Until strFile = vbNullString
  

MsgBox "Success: - Export Complete"

End Sub


Go to topic 5745

Return to index page 1018
Return to index page 1017
Return to index page 1016
Return to index page 1015
Return to index page 1014
Return to index page 1013
Return to index page 1012
Return to index page 1011
Return to index page 1010
Return to index page 1009