?
Solved

Saving Crystal Report to PDF file through Visual Basic, using API.

Posted on 2008-09-29
2
Medium Priority
?
2,354 Views
Last Modified: 2012-05-05
Hello everybody and thanks for looking.
Basically what I need is to call needed methods to save the report in PDF format somewhere on the disk. Here is the code for the report itself, but you don't have to look at it if you know the right sequence of methods to call.

Thanks again.

PS I would imagine it being something similar to lines 279-281.
'  03/25/04 - VKG - Call WD? V9.2A and above
'                   delay command added.
'  03/28/06 - VKG - WD7046 V9.30
'                   Page setup logic suppressed
 
Public Const INVALID_HANDLE_VALUE = -1
Public Const MAX_PATH = 260
 
Public Type FILETIME
   dwLowDateTime As Long
   dwHighDateTime As Long
End Type
 
Public Type WIN32_FIND_DATA
   dwFileAttributes As Long
   ftCreationTime As FILETIME
   ftLastAccessTime As FILETIME
   ftLastWriteTime As FILETIME
   nFileSizeHigh As Long
   nFileSizeLow As Long
   dwReserved0 As Long
   dwReserved1 As Long
   cFileName As String * MAX_PATH
   cAlternate As String * 14
End Type
 
Public Declare Function FindFirstFile Lib "kernel32" _
   Alias "FindFirstFileA" _
  (ByVal lpFileName As String, _
   lpFindFileData As WIN32_FIND_DATA) As Long
 
Public Declare Function FindClose Lib "kernel32" _
  (ByVal hFindFile As Long) As Long
 
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpclassname As String, ByVal lpwindowname As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
  "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
  lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, _
  ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
  "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
  lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
 
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliSeconds As Long)
    
'Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
'Declare Function GetActiveWindow Lib "user32" () As Integer
'Declare Function IsWindow Lib "user32" Alias "IsWindowA" (ByVal hWnd As Integer) As Boolean ' 12/1/97 - changed return data type from string to Boolean
'Declare Function GetCurrentTask Lib "Kernel32" () As Integer
'Declare Sub BringWindowToTop Lib "user32" (ByVal hWnd As Integer)
 
' 10/21/97 - jao - made vars public so clean-up procedure in timer event can read them
' 04/18/03 - bgk - Call #1-9753 v9.2a Crystal 9
'                  Changed variable fieldcount to long from int.
'                  Call #1-9847 v9.2a Crystal 9
'                  Added PrintSetup prior to actual Print dialogue.
 
Public reportname As String
Public pathname As String
Public newshop As String
 
Public startcounter As Long
Public endcounter As Long
Public readline As String
Public linevar As String
Public fieldcount As Long
 
Public vDebug As Boolean
 
Dim crxApplication As New CRAXDRT.Application
Public Report         As CRAXDRT.Report
Public SubReport      As CRAXDRT.Report
 
Public DrillDown As Boolean
Public GoAway As Boolean
 
Public temp As Long
Public tempclip As String
Public titleString As String
Public emptyflag As Boolean
Public BytPic() As Byte
Public BytPic1() As Byte
Public BytPic2() As Byte
Public LngLoop As Long
Public uplimit As Long
Public errfile As String
Public lastpic1 As String
Public lastpic2 As String
Public dbDelayms As Integer
Public previewDelayms As Integer
Public saveDelayms As Integer
Public printDelayms As Integer
Public fileName As String
 
Public vDataStatus As String
Public vSaveFile As String
Public vSendTo As String
 
Public hwndPreviewWindow As Long
 
Public Sub Main()
    'Main block to load data and connect crystal report
 
    vDebug = FileExists(App.Path + "\DebugTabDataXI.txt")
    vDataStatus = ""
    
    If vDebug Then
      DisplayErrorMessage ("In Main Block")
    End If
    
    emptyflag = False
    dbDelayms = 0
    previewDelayms = 0
    saveDelayms = 0
    printDelayms = 0
    
    ' error handling
    On Error GoTo errsub
    
    ' 12/1/97 - add check for an instance of Crystal, abort if so
    
    hwndPreviewWindow = FindWindow(vbNullString, "Encompix Report")
    If hwndPreviewWindow = 0 Then
            ' window not found
    Else
        MsgBox "Error - An Encompix Report is already active on your system." + Chr$(13) + "Please close the report preview window and try this report again.", 4160, "Encompix Report"
        Clipboard.Clear
        Clipboard.SetText "ERROR", vbCFText
        GoTo endproc
    End If
    
    GoAway = False
    
    tempclip = Clipboard.GetText(vbCFText)
    
    ' jao - 10/09/97 - parse pathname from the passed reportname string
    temp = 0
    For temp = Len(tempclip) To 1 Step -1
        If Mid$(tempclip, temp, 1) = "|" Then Exit For
    Next temp
    
    pathname = Mid$(tempclip, 1, temp - 1)
    'reportname = App.Path + "\" + Mid$(tempclip, temp + 1)
    reportname = Mid$(tempclip, temp + 1)
    titleString = Mid$(tempclip, temp + 1)
    
    temp = 0
    For temp = Len(titleString) To 1 Step -1
        If Mid$(titleString, temp, 1) = "\" Then Exit For
    Next temp
    
    'TitleString = "arcust.rpt"
    titleString = Mid$(titleString, temp + 1, Len(titleString))
    If vDebug Then
      DisplayErrorMessage ("Title String = " & titleString)
    End If
    
    newshop = pathname + "shoprpt.mdb"
    
    If vDebug Then
      DisplayErrorMessage ("Access DB Path = " & newshop)
    End If
    
    fileName = pathname + "crystal.ini"
    If vDebug Then
      DisplayErrorMessage ("Crystal INI = " & fileName)
    End If
    
    ' Create table1
    Call LoadTable1
    If vDataStatus = "ERROR" Then
        GoTo endproc
    End If
    
    If vDebug Then
      DisplayErrorMessage ("TABLE1 loaded")
    End If
    
    ' Create table2
    Call LoadTable2
        
    If vDebug Then
      DisplayErrorMessage ("TABLE2 loaded")
    End If
    
    ' Create table3
    Call LoadTable3
 
    If vDebug Then
      DisplayErrorMessage ("TABLE3 loaded")
    End If
    
    ' Create table4
    Call LoadTable4
 
    If vDebug Then
      DisplayErrorMessage ("TABLE4 loaded")
    End If
 
    ' reportname = Trim(LCase(reportname))
    Dim crxDBTable     As CRAXDRT.DatabaseTable
    
    If FileExists(fileName) Then
      If GetFromINI(fileName, "EncompixCrystal", "DBDelay") <> "" Then
        dbDelayms = CInt(GetFromINI(fileName, "EncompixCrystal", "DBDelay"))
      End If
      If GetFromINI(fileName, "EncompixCrystal", "PreviewDelay") <> "" Then
        previewDelayms = CInt(GetFromINI(fileName, "EncompixCrystal", "PreviewDelay"))
      End If
      If GetFromINI(fileName, "EncompixCrystal", "SaveDelay") <> "" Then
        saveDelayms = CInt(GetFromINI(fileName, "EncompixCrystal", "SaveDelay"))
      End If
      If GetFromINI(fileName, "EncompixCrystal", "PrintDelay") <> "" Then
        printDelayms = CInt(GetFromINI(fileName, "EncompixCrystal", "PrintDelay"))
      End If
    End If
    
    If vDebug Then
       DisplayErrorMessage ("Report Path = " & reportname)
    End If
    
    'MsgBox "Report name " & reportname
    Set Report = crxApplication.OpenReport(reportname, 1)
    
    'MsgBox "pathname " & pathname
    For Each crxDBTable In Report.Database.Tables
      crxDBTable.Location = pathname & "shoprpt.mdb"
     
    Next crxDBTable
    
    If dbDelayms <> 0 Then
      Sleep dbDelayms
    End If
    
    Form1.CrRptXI.DisplayGroupTree = False
    Form1.CrRptXI.ReportSource = Report
    Form1.CrRptXI.ViewReport
    
    Report.SetDialogParentWindow (Form1.hWnd)
    Report.ReportTitle = titleString
    
    'Form1.reports.object.Cancel
    'create error condition if Cancel pressed
    'choose direction for printing report
    
    If vDebug Then
       DisplayErrorMessage ("Send To = " & vSendTo)
    End If
    
    Select Case vSendTo
    Case "P" ' send directly to a printer
        
               If vDebug Then
            DisplayErrorMessage ("Printer block")
        End If
        'Printer setup command prompts for page setup dialog box
        'Report.PrinterSetup Form1.hWnd
        If printDelayms <> 0 Then
          Sleep printDelayms
        End If
        
        Report.PrintOut True
        CleanUp
        
 
 
        
        
        
    Case "S"   ' save as a text file
        If vDebug Then
            DisplayErrorMessage ("Save block")
        End If
    
        If saveDelayms <> 0 Then
          Sleep saveDelayms
        End If
        'savefile = vSaveFile
        Report.ExportOptions.FormatType = crEFTPortableDocFormat
        Report.ExportOptions.DestinationType = crEDTDiskFile
        Report.ExportOptions.DiskFileName = vSaveFile
        
               '
' create com api object
'
Set myobj = CreateObject("fmfaxapi.application")
 
If IsObject(myobj) Then
    '
    ' add recpient(s)
    '
    myobj.addrecipient danfax
    '
    ' commands for addattachment are case sensitive so they must be in lower case
    '
    If myobj.addattachment(vSaveFile) Then
        '
        ' print to the faxmaker printer driver
        '
        If myobj.addattachment(vSaveFile) Then
            '
            ' at this point the print job is attached as a fax file
            '
        Else
            '
            ' failed to attach the print job/timeout ; exit
            '
        End If
    End If
    '
    ' wait.print.close must always be called even if wait.print.setup fails
    '
    myobj.addattachment "wait.print.close"
 
    '
    ' submit the fax
    '
    myobj.sendfax
 
End If
'
' release object
'
Set myobj = Nothing
        Report.Export
        CleanUp
    
    Case Else  'preview on screen
        If vDebug Then
            DisplayErrorMessage ("Preview block")
        End If
        If previewDelayms <> 0 Then
          Sleep previewDelayms
        End If
        Form1.Show
        Form1.WindowState = 2
        Form1.Timer1.Enabled = True  ' check every x seconds for window close - end VB routine when closed
      
    End Select
    GoTo endproc
    
errsub:
    
    'If Err = cdlCancel Then End
 
    MsgBox "Error - " + Error(Err) + Chr(10) + "File - " + errfile, 16
    End
    
endproc:
 
End Sub
 
Public Sub CleanUp()
    On Error Resume Next
    
    '    Kill pathname + "table?.txt"
    '    Kill pathname + "shoprpt.*"
    
    End
End Sub
 
Public Sub getstring()
    'Get field data. Each field is separated by TAB
 
    fieldcount = fieldcount + 1
    
    endcounter = InStr(startcounter + 1, readline, Chr$(9))
    
    If endcounter = startcounter + 1 Then
        linevar = ""
    Else
        linevar = Mid$(readline, startcounter + 1, (endcounter - startcounter) - 1)
    End If
    
    'Debug.Print startcounter, endcounter, linevar, fieldcount
    
    
    startcounter = endcounter
 
End Sub
 
Public Sub DisplayErrorMessage(ByVal ipMessage As String)
    'Display error message if debug value is true
    MsgBox ipMessage, vbInformation, "Encompix Debugger"
 
End Sub
 
Public Function GetFromINI(strFile As String, strSection As String, _
            strKey As String) As String
    'Get Key from INI file
    
    Dim strDefault          As String 'Default Return Value if key not present
    Dim strReturn           As String 'Return Value
    Dim lngReturn           As Long   'Length of Return Value
    strDefault = " "
    strReturn = Space$(255)              '<-- Add this line
    lngReturn = GetPrivateProfileString(strSection, strKey, strDefault, _
        strReturn, 255, strFile)
    GetFromINI = Left(strReturn, lngReturn)
End Function
   
 
Public Function FileExists(sSource As String) As Boolean
    'Check if file exists
 
    Dim WFD As WIN32_FIND_DATA
    Dim hFile As Long
    
    hFile = FindFirstFile(sSource, WFD)
    FileExists = hFile <> INVALID_HANDLE_VALUE
    
    Call FindClose(hFile)
   
End Function
 
Public Sub LoadTable1()
    'Load table1 data
 
    Dim rstable1 As Recordset
    
    Set dbReport = Workspaces(0).OpenDatabase(newshop)
    Set rstable1 = dbReport.OpenRecordset("table1", dbOpenDynaset)
    
    Dim removereport As String
    
    Dim InputTable As String
    InputTable = pathname + "table1.txt"
    Open InputTable For Input As #1
            
    If EOF(1) Then
        MsgBox "No data in report.", 4160, "Encompix Report"
        Clipboard.Clear
        Clipboard.SetText "ERROR", vbCFText
        vDataStatus = "ERROR"
        GoTo EndSubLoadTable1
    End If
            
    Do While Not EOF(1)
    
        errfile = Trim(reportname)
        
        Line Input #1, readline
    
        startcounter = 0
        endcounter = 0
            
        rstable1.AddNew
        getstring
        rstable1("t1c1") = linevar
        
        ' check for no data in field 1 only on first pass thru
        If linevar = "" And Not emptyflag Then
            MsgBox "No data in report.", 4160, "Encompix Report"
            Clipboard.Clear
            Clipboard.SetText "ERROR", vbCFText
            vDataStatus = "ERROR"
            GoTo EndSubLoadTable1
        End If
        emptyflag = True
                    
        getstring                           '1
        rstable1("t1c2") = linevar
        getstring                           '2
        rstable1("t1c3") = linevar
        getstring                           '3
        rstable1("t1c4") = linevar
        getstring                           '4
        rstable1("t1c5") = linevar
        getstring                           '5
        rstable1("t1c6") = linevar
        getstring                           '6
        rstable1("t1c7") = linevar
        getstring                           '7
        rstable1("t1c8") = linevar
        getstring                           '8
        rstable1("t1c9") = linevar
        getstring                           '9
        rstable1("t1c10") = linevar
        getstring                           '10
        rstable1("t1c11") = linevar
        getstring                           '11
        rstable1("t1c12") = linevar
        getstring                           '12
        rstable1("t1c13") = linevar
        getstring                           '13
        rstable1("t1c14") = linevar
        getstring                           '14
        rstable1("t1c15") = linevar
        getstring                           '15
        rstable1("t1c16") = linevar
        getstring                           '16
        rstable1("t1c17") = linevar
        getstring                           '17
        rstable1("t1c18") = linevar
        getstring                           '18
        rstable1("t1c19") = linevar
        getstring                           '19
        rstable1("t1c20") = linevar
        getstring                           '10
        rstable1("t1c21") = linevar
        getstring                           '11
        rstable1("t1c22") = linevar
        getstring                           '12
        rstable1("t1c23") = linevar
        getstring                           '13
        rstable1("t1c24") = linevar
        getstring                           '14
        rstable1("t1c25") = linevar
        getstring                           '15
        rstable1("t1c26") = linevar
        getstring                           '16
        rstable1("t1c27") = linevar
        getstring                           '17
        rstable1("t1c28") = linevar
        getstring                           '18
        rstable1("t1c29") = linevar
        getstring                           '19
        rstable1("t1c30") = linevar
        getstring                           '10
        rstable1("t1c31") = linevar
        getstring                           '11
        rstable1("t1c32") = linevar
        getstring                           '12
        rstable1("t1c33") = linevar
        getstring                           '13
        rstable1("t1c34") = linevar
        getstring                           '14
        rstable1("t1c35") = linevar
        getstring                           '15
        rstable1("t1c36") = linevar
        getstring                           '16
        rstable1("t1c37") = linevar
        getstring                           '17
        rstable1("t1c38") = linevar
        getstring                           '18
        rstable1("t1c39") = linevar
        getstring                           '19
        rstable1("t1c40") = linevar
        getstring                           '20
        rstable1("t1d1") = Val(linevar)
        getstring                           '21
        rstable1("t1d2") = Val(linevar)
        getstring                           '22
        rstable1("t1d3") = Val(linevar)
        getstring                           '23
        rstable1("t1d4") = Val(linevar)
        getstring                           '24
        rstable1("t1d5") = Val(linevar)
        getstring                           '25
        rstable1("t1d6") = Val(linevar)
        getstring                           '26
        rstable1("t1d7") = Val(linevar)
        getstring                           '27
        rstable1("t1d8") = Val(linevar)
        getstring                           '28
        rstable1("t1d9") = Val(linevar)
        getstring                           '29
        rstable1("t1d10") = Val(linevar)
        getstring                           '30
        rstable1("t1d11") = Val(linevar)
        getstring                           '31
        rstable1("t1d12") = Val(linevar)
        getstring                           '32
        rstable1("t1d13") = Val(linevar)
        getstring                           '33
        rstable1("t1d14") = Val(linevar)
        getstring                           '34
        rstable1("t1d15") = Val(linevar)
        getstring                           '35
        rstable1("t1d16") = Val(linevar)
        getstring                           '36
        rstable1("t1d17") = Val(linevar)
        getstring                           '37
        rstable1("t1d18") = Val(linevar)
        getstring                           '38
        rstable1("t1d19") = Val(linevar)
        getstring                           '39
        rstable1("t1d20") = Val(linevar)
        getstring                           '40
        If linevar = "no" Then rstable1("t1b1") = False Else rstable1("t1b1") = True
        getstring                           '41
        If linevar = "no" Then rstable1("t1b2") = False Else rstable1("t1b2") = True
        getstring                           '42
        rstable1("t1v1") = linevar
        vSendTo = linevar
        getstring                           '43
        rstable1("t1v2") = linevar
        vSaveFile = linevar
        getstring                           '44
        rstable1("t1v3") = linevar
        getstring                           '45
        rstable1("t1v4") = linevar
        getstring                           '46
        rstable1("t1v5") = linevar
        getstring                           '47
        rstable1("t1v6") = linevar
        getstring                           '48
        rstable1("t1v7") = linevar
        getstring                           '49
        rstable1("t1v8") = linevar
        getstring                           '50
        rstable1("t1v9") = linevar
        getstring                           '51
        rstable1("t1v10") = linevar
        getstring                           '52
        rstable1("t1p1") = linevar
        getstring                           '53
        rstable1("t1p2") = linevar
        getstring                           '54
        rstable1("t1p3") = linevar
        getstring                           '55
        rstable1("t1p4") = linevar
        getstring                           '56
        rstable1("t1p5") = linevar
        getstring                           '57
        rstable1("t1p6") = linevar
        getstring                           '58
        rstable1("t1p7") = linevar
        getstring                           '59
        rstable1("t1p8") = linevar
        getstring                           '60
        rstable1("t1p9") = linevar
        getstring                           '61
        rstable1("t1p10") = linevar
        getstring                           '62
        If linevar <> "" Then
            If lastpic1 <> linevar Then ' if bitmap filename changed, then re-load bitmap from disk
                lastpic1 = linevar
                errfile = linevar
                Open linevar For Binary As #5
                
                If LOF(5) > 65536 Then ' check bitmap for allowed size
                    MsgBox "OLE field is over maximum value of 65536 bytes.", vbOKOnly + vbCritical
                    Clipboard.Clear
                    Clipboard.SetText "ERROR", vbCFText
                    End
                End If
                
                ReDim BytPic1(LOF(5)) ' load OLE object into byte array
                For LngLoop = 0 To UBound(BytPic1)
                    Get #5, , BytPic1(LngLoop)
                Next
            End If
            
            ' load OLE object from memory to access field
            uplimit = UBound(BytPic1)
            If uplimit > 32768 Then ' if OLE object is greater than allowed chunk size of 32k
                    
                    ReDim BytPic(32768) ' first chunk
                    For LngLoop = 0 To 32768
                        BytPic(LngLoop) = BytPic1(LngLoop)
                    Next
                    rstable1("t1ole1").AppendChunk BytPic()
                    
                    ReDim BytPic(uplimit - 32768) ' next chunk
                    For LngLoop = 0 To UBound(BytPic)
                        BytPic(LngLoop) = BytPic1(LngLoop + 32768)
                    Next
                    rstable1("t1ole1").AppendChunk BytPic()
            Else
                    ReDim BytPic(uplimit) ' first chunk
                    For LngLoop = 0 To uplimit
                        BytPic(LngLoop) = BytPic1(LngLoop)
                    Next
                    rstable1("t1ole1").AppendChunk BytPic()
            End If
                
                
            Close #5
        
        End If
        
        getstring                           '63
        If linevar <> "" Then
            If lastpic2 <> linevar Then ' if bitmap filename changed, then re-load bitmap from disk
                lastpic2 = linevar
                errfile = linevar
                Open linevar For Binary As #5
                
                If LOF(5) > 65536 Then ' check bitmap for allowed size
                    MsgBox "OLE field is over maximum value of 65536 bytes.", vbOKOnly + vbCritical
                    Clipboard.Clear
                    Clipboard.SetText "ERROR", vbCFText
                    End
                End If
                
                ReDim BytPic2(LOF(5)) ' load OLE object into byte array
                For LngLoop = 0 To UBound(BytPic2)
                    Get #5, , BytPic2(LngLoop)
                Next
            End If
        
            ' load OLE object from memory to access field
            uplimit = UBound(BytPic2)
            If uplimit > 32768 Then ' if OLE object is greater than allowed chunk size of 32k
                    
                    ReDim BytPic(32768) ' first chunk
                    For LngLoop = 0 To 32768
                        BytPic(LngLoop) = BytPic2(LngLoop)
                    Next
                    rstable1("t1ole2").AppendChunk BytPic()
                    
                    ReDim BytPic(uplimit - 32768) ' next chunk
                    For LngLoop = 0 To UBound(BytPic)
                        BytPic(LngLoop) = BytPic2(LngLoop + 32768)
                    Next
                    rstable1("t1ole2").AppendChunk BytPic()
            Else
                    ReDim BytPic(uplimit) ' first chunk
                    For LngLoop = 0 To uplimit
                        BytPic(LngLoop) = BytPic2(LngLoop)
                    Next
                    rstable1("t1ole2").AppendChunk BytPic()
            End If
                
                
            Close #5
        
        End If
        
        rstable1.Update  ' update record
    
    Loop
 
EndSubLoadTable1:
 
    Close #1
 
End Sub
 
Public Sub LoadTable2()
    'Load table2 data
    Dim rstable2 As Recordset
    
    Set dbReport = Workspaces(0).OpenDatabase(newshop)
    Set rstable2 = dbReport.OpenRecordset("table2", dbOpenDynaset)
        
    InputTable = pathname + "table2.txt"
    Open InputTable For Input As #1
            
    If EOF(1) Then GoTo skip2 ' Skip table 2 generation if file is zero-length
                
    Do While Not EOF(1)
    
    errfile = reportname
    Line Input #1, readline
    
    startcounter = 0
    endcounter = 0
                        
            rstable2.AddNew
            getstring
            rstable2("t2c1") = linevar
            getstring
            rstable2("t2c2") = linevar
            getstring
            rstable2("t2c3") = linevar
            getstring
            rstable2("t2c4") = linevar
            getstring
            rstable2("t2c5") = linevar
            getstring
            rstable2("t2c6") = linevar
            getstring
            rstable2("t2c7") = linevar
            getstring
            rstable2("t2c8") = linevar
            getstring
            rstable2("t2c9") = linevar
            getstring
            rstable2("t2c10") = linevar
            getstring
            rstable2("t2c11") = linevar
            getstring
            rstable2("t2c12") = linevar
            getstring
            rstable2("t2c13") = linevar
            getstring
            rstable2("t2c14") = linevar
            getstring
            rstable2("t2c15") = linevar
            getstring
            rstable2("t2c16") = linevar
            getstring
            rstable2("t2c17") = linevar
            getstring
            rstable2("t2c18") = linevar
            getstring
            rstable2("t2c19") = linevar
            getstring
            rstable2("t2c20") = linevar
            getstring                           '10
            rstable2("t2c21") = linevar
            getstring                           '11
            rstable2("t2c22") = linevar
            getstring                           '12
            rstable2("t2c23") = linevar
            getstring                           '13
            rstable2("t2c24") = linevar
            getstring                           '14
            rstable2("t2c25") = linevar
            getstring                           '15
            rstable2("t2c26") = linevar
            getstring                           '16
            rstable2("t2c27") = linevar
            getstring                           '17
            rstable2("t2c28") = linevar
            getstring                           '18
            rstable2("t2c29") = linevar
            getstring                           '19
            rstable2("t2c30") = linevar
            getstring                           '10
            rstable2("t2c31") = linevar
            getstring                           '11
            rstable2("t2c32") = linevar
            getstring                           '12
            rstable2("t2c33") = linevar
            getstring                           '13
            rstable2("t2c34") = linevar
            getstring                           '14
            rstable2("t2c35") = linevar
            getstring                           '15
            rstable2("t2c36") = linevar
            getstring                           '16
            rstable2("t2c37") = linevar
            getstring                           '17
            rstable2("t2c38") = linevar
            getstring                           '18
            rstable2("t2c39") = linevar
            getstring                           '19
            rstable2("t2c40") = linevar
            getstring
            rstable2("t2d1") = Val(linevar)
            getstring
            rstable2("t2d2") = Val(linevar)
            getstring
            rstable2("t2d3") = Val(linevar)
            getstring
            rstable2("t2d4") = Val(linevar)
            getstring
            rstable2("t2d5") = Val(linevar)
            getstring
            rstable2("t2d6") = Val(linevar)
            getstring
            rstable2("t2d7") = Val(linevar)
            getstring
            rstable2("t2d8") = Val(linevar)
            getstring
            rstable2("t2d9") = Val(linevar)
            getstring
            rstable2("t2d10") = Val(linevar)
            getstring
            rstable2("t2d11") = Val(linevar)
            getstring
            rstable2("t2d12") = Val(linevar)
            getstring
            rstable2("t2d13") = Val(linevar)
            getstring
            rstable2("t2d14") = Val(linevar)
            getstring
            rstable2("t2d15") = Val(linevar)
            getstring
            rstable2("t2d16") = Val(linevar)
            getstring
            rstable2("t2d17") = Val(linevar)
            getstring
            rstable2("t2d18") = Val(linevar)
            getstring
            rstable2("t2d19") = Val(linevar)
            getstring
            rstable2("t2d20") = Val(linevar)
            getstring
            If linevar = "no" Then rstable2("t2b1") = False Else rstable2("t2b1") = True
            getstring
            If linevar = "no" Then rstable2("t2b2") = False Else rstable2("t2b2") = True
            getstring
            rstable2("t2v1") = linevar
            t2v1 = linevar
            getstring
            rstable2("t2v2") = linevar
            getstring
            rstable2("t2v3") = linevar
            getstring
            rstable2("t2v4") = linevar
            getstring
            rstable2("t2v5") = linevar
            getstring
            rstable2("t2v6") = linevar
            getstring
            rstable2("t2v7") = linevar
            getstring
            rstable2("t2v8") = linevar
            getstring
            rstable2("t2v9") = linevar
            getstring
            rstable2("t2v10") = linevar
            getstring
            rstable2("t2p1") = linevar
            getstring
            rstable2("t2p2") = linevar
            getstring
            rstable2("t2p3") = linevar
            getstring
            rstable2("t2p4") = linevar
            getstring
            rstable2("t2p5") = linevar
            getstring
            rstable2("t2p6") = linevar
            getstring
            rstable2("t2p7") = linevar
            getstring
            rstable2("t2p8") = linevar
            getstring
            rstable2("t2p9") = linevar
            getstring
            rstable2("t2p10") = linevar
            rstable2.Update
    Loop
    
skip2:
    Close #1
    
End Sub
 
Public Sub LoadTable3()
    'Load table3 data
 
    Dim rstable3 As Recordset
    
    Set dbReport = Workspaces(0).OpenDatabase(newshop)
    Set rstable3 = dbReport.OpenRecordset("table3", dbOpenDynaset)
        
    InputTable = pathname + "table3.txt"
    Open InputTable For Input As #1
            
    If EOF(1) Then GoTo skip3 ' Skip table 3 generation if file is zero-length
                
    Do While Not EOF(1)
    
    errfile = reportname
    Line Input #1, readline
    
    startcounter = 0
    endcounter = 0
                        
            rstable3.AddNew
            getstring
            rstable3("t3c1") = linevar
            getstring
            rstable3("t3c2") = linevar
            getstring
            rstable3("t3c3") = linevar
            getstring
            rstable3("t3c4") = linevar
            getstring
            rstable3("t3c5") = linevar
            getstring
            rstable3("t3c6") = linevar
            getstring
            rstable3("t3c7") = linevar
            getstring
            rstable3("t3c8") = linevar
            getstring
            rstable3("t3c9") = linevar
            getstring
            rstable3("t3c10") = linevar
            getstring
            rstable3("t3c11") = linevar
            getstring
            rstable3("t3c12") = linevar
            getstring
            rstable3("t3c13") = linevar
            getstring
            rstable3("t3c14") = linevar
            getstring
            rstable3("t3c15") = linevar
            getstring
            rstable3("t3c16") = linevar
            getstring
            rstable3("t3c17") = linevar
            getstring
            rstable3("t3c18") = linevar
            getstring
            rstable3("t3c19") = linevar
            getstring
            rstable3("t3c20") = linevar
            getstring                           '10
            rstable3("t3c21") = linevar
            getstring                           '11
            rstable3("t3c22") = linevar
            getstring                           '12
            rstable3("t3c23") = linevar
            getstring                           '13
            rstable3("t3c24") = linevar
            getstring                           '14
            rstable3("t3c25") = linevar
            getstring                           '15
            rstable3("t3c26") = linevar
            getstring                           '16
            rstable3("t3c27") = linevar
            getstring                           '17
            rstable3("t3c28") = linevar
            getstring                           '18
            rstable3("t3c29") = linevar
            getstring                           '19
            rstable3("t3c30") = linevar
            getstring                           '10
            rstable3("t3c31") = linevar
            getstring                           '11
            rstable3("t3c32") = linevar
            getstring                           '12
            rstable3("t3c33") = linevar
            getstring                           '13
            rstable3("t3c34") = linevar
            getstring                           '14
            rstable3("t3c35") = linevar
            getstring                           '15
            rstable3("t3c36") = linevar
            getstring                           '16
            rstable3("t3c37") = linevar
            getstring                           '17
            rstable3("t3c38") = linevar
            getstring                           '18
            rstable3("t3c39") = linevar
            getstring                           '19
            rstable3("t3c40") = linevar
            getstring
            rstable3("t3d1") = Val(linevar)
            getstring
            rstable3("t3d2") = Val(linevar)
            getstring
            rstable3("t3d3") = Val(linevar)
            getstring
            rstable3("t3d4") = Val(linevar)
            getstring
            rstable3("t3d5") = Val(linevar)
            getstring
            rstable3("t3d6") = Val(linevar)
            getstring
            rstable3("t3d7") = Val(linevar)
            getstring
            rstable3("t3d8") = Val(linevar)
            getstring
            rstable3("t3d9") = Val(linevar)
            getstring
            rstable3("t3d10") = Val(linevar)
            getstring
            rstable3("t3d11") = Val(linevar)
            getstring
            rstable3("t3d12") = Val(linevar)
            getstring
            rstable3("t3d13") = Val(linevar)
            getstring
            rstable3("t3d14") = Val(linevar)
            getstring
            rstable3("t3d15") = Val(linevar)
            getstring
            rstable3("t3d16") = Val(linevar)
            getstring
            rstable3("t3d17") = Val(linevar)
            getstring
            rstable3("t3d18") = Val(linevar)
            getstring
            rstable3("t3d19") = Val(linevar)
            getstring
            rstable3("t3d20") = Val(linevar)
            getstring
            If linevar = "no" Then rstable3("t3b1") = False Else rstable3("t3b1") = True
            getstring
            If linevar = "no" Then rstable3("t3b2") = False Else rstable3("t3b2") = True
            getstring
            rstable3("t3v1") = linevar
            t3v1 = linevar
            getstring
            rstable3("t3v2") = linevar
            getstring
            rstable3("t3v3") = linevar
            getstring
            rstable3("t3v4") = linevar
            getstring
            rstable3("t3v5") = linevar
            getstring
            rstable3("t3v6") = linevar
            getstring
            rstable3("t3v7") = linevar
            getstring
            rstable3("t3v8") = linevar
            getstring
            rstable3("t3v9") = linevar
            getstring
            rstable3("t3v10") = linevar
            getstring
            rstable3("t3p1") = linevar
            getstring
            rstable3("t3p2") = linevar
            getstring
            rstable3("t3p3") = linevar
            getstring
            rstable3("t3p4") = linevar
            getstring
            rstable3("t3p5") = linevar
            getstring
            rstable3("t3p6") = linevar
            getstring
            rstable3("t3p7") = linevar
            getstring
            rstable3("t3p8") = linevar
            getstring
            rstable3("t3p9") = linevar
            getstring
            rstable3("t3p10") = linevar
            rstable3.Update
    Loop
    
skip3:
 
    Close #1
 
End Sub
 
Public Sub LoadTable4()
    'Load table4 data
 
    Dim rstable4 As Recordset
    
    Set dbReport = Workspaces(0).OpenDatabase(newshop)
    Set rstable4 = dbReport.OpenRecordset("table4", dbOpenDynaset)
        
    InputTable = pathname + "table4.txt"
    Open InputTable For Input As #1
            
    If EOF(1) Then GoTo skip4 ' Skip table 4 generation if file is zero-length
                
    Do While Not EOF(1)
    
    errfile = reportname
    Line Input #1, readline
    
    startcounter = 0
    endcounter = 0
                        
            rstable4.AddNew
            getstring
            rstable4("t4c1") = linevar
            getstring
            rstable4("t4c2") = linevar
            getstring
            rstable4("t4c3") = linevar
            getstring
            rstable4("t4c4") = linevar
            getstring
            rstable4("t4c5") = linevar
            getstring
            rstable4("t4c6") = linevar
            getstring
            rstable4("t4c7") = linevar
            getstring
            rstable4("t4c8") = linevar
            getstring
            rstable4("t4c9") = linevar
            getstring
            rstable4("t4c10") = linevar
            getstring
            rstable4("t4c11") = linevar
            getstring
            rstable4("t4c12") = linevar
            getstring
            rstable4("t4c13") = linevar
            getstring
            rstable4("t4c14") = linevar
            getstring
            rstable4("t4c15") = linevar
            getstring
            rstable4("t4c16") = linevar
            getstring
            rstable4("t4c17") = linevar
            getstring
            rstable4("t4c18") = linevar
            getstring
            rstable4("t4c19") = linevar
            getstring
            rstable4("t4c20") = linevar
            getstring                           '10
            rstable4("t4c21") = linevar
            getstring                           '11
            rstable4("t4c22") = linevar
            getstring                           '12
            rstable4("t4c23") = linevar
            getstring                           '13
            rstable4("t4c24") = linevar
            getstring                           '14
            rstable4("t4c25") = linevar
            getstring                           '15
            rstable4("t4c26") = linevar
            getstring                           '16
            rstable4("t4c27") = linevar
            getstring                           '17
            rstable4("t4c28") = linevar
            getstring                           '18
            rstable4("t4c29") = linevar
            getstring                           '19
            rstable4("t4c30") = linevar
            getstring                           '10
            rstable4("t4c31") = linevar
            getstring                           '11
            rstable4("t4c32") = linevar
            getstring                           '12
            rstable4("t4c33") = linevar
            getstring                           '13
            rstable4("t4c34") = linevar
            getstring                           '14
            rstable4("t4c35") = linevar
            getstring                           '15
            rstable4("t4c36") = linevar
            getstring                           '16
            rstable4("t4c37") = linevar
            getstring                           '17
            rstable4("t4c38") = linevar
            getstring                           '18
            rstable4("t4c39") = linevar
            getstring                           '19
            rstable4("t4c40") = linevar
            getstring
            rstable4("t4d1") = Val(linevar)
            getstring
            rstable4("t4d2") = Val(linevar)
            getstring
            rstable4("t4d3") = Val(linevar)
            getstring
            rstable4("t4d4") = Val(linevar)
            getstring
            rstable4("t4d5") = Val(linevar)
            getstring
            rstable4("t4d6") = Val(linevar)
            getstring
            rstable4("t4d7") = Val(linevar)
            getstring
            rstable4("t4d8") = Val(linevar)
            getstring
            rstable4("t4d9") = Val(linevar)
            getstring
            rstable4("t4d10") = Val(linevar)
            getstring
            rstable4("t4d11") = Val(linevar)
            getstring
            rstable4("t4d12") = Val(linevar)
            getstring
            rstable4("t4d13") = Val(linevar)
            getstring
            rstable4("t4d14") = Val(linevar)
            getstring
            rstable4("t4d15") = Val(linevar)
            getstring
            rstable4("t4d16") = Val(linevar)
            getstring
            rstable4("t4d17") = Val(linevar)
            getstring
            rstable4("t4d18") = Val(linevar)
            getstring
            rstable4("t4d19") = Val(linevar)
            getstring
            rstable4("t4d20") = Val(linevar)
            getstring
            If linevar = "no" Then rstable4("t4b1") = False Else rstable4("t4b1") = True
            getstring
            If linevar = "no" Then rstable4("t4b2") = False Else rstable4("t4b2") = True
            getstring
            rstable4("t4v1") = linevar
            t4v1 = linevar
            getstring
            rstable4("t4v2") = linevar
            getstring
            rstable4("t4v3") = linevar
            getstring
            rstable4("t4v4") = linevar
            getstring
            rstable4("t4v5") = linevar
            getstring
            rstable4("t4v6") = linevar
            getstring
            rstable4("t4v7") = linevar
            getstring
            rstable4("t4v8") = linevar
            getstring
            rstable4("t4v9") = linevar
            getstring
            rstable4("t4v10") = linevar
            getstring
            rstable4("t4p1") = linevar
            getstring
            rstable4("t4p2") = linevar
            getstring
            rstable4("t4p3") = linevar
            getstring
            rstable4("t4p4") = linevar
            getstring
            rstable4("t4p5") = linevar
            getstring
            rstable4("t4p6") = linevar
            getstring
            rstable4("t4p7") = linevar
            getstring
            rstable4("t4p8") = linevar
            getstring
            rstable4("t4p9") = linevar
            getstring
            rstable4("t4p10") = linevar
            rstable4.Update
    Loop
 
skip4:
    
        Close #1
 
End Sub

Open in new window

0
Comment
Question by:danwendt1
[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
2 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 22598314
hERE IS THE  CODE i USE

Option Explicit
    Private crApp As CRAXDRT.Application
    Private crRpt As CRAXDRT.Report

'
'   Open report
'
    Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport("C:\Crystal\MyRepots\My_Report.rpt",1)

'
'   Set export options
'
   crRpt.ExportOptions.DestinationType =   credteDiskFile
   crRpt.ExportOptions.DestinationType =  crEFTPortableDocFormat
   crRpt.ExportOptions.FileName = "Some path and filename"

    crRpt.Export False

MLMCC
0
 

Author Comment

by:danwendt1
ID: 22609850
thanks mlmcc.. u r to my rescue once again :D
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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