        StrSor = "D:\DAILY_BOOKING.xls"

    Dim xlApp As Excel.Application                                  'ExcelӦó
    Dim xlBook As Excel.Workbook                                    'Excel
    Dim xlSheet As Excel.Worksheet                                  'Excel
    Dim dbs As Database, strSQL As String, x As Integer
    Dim qdf As QueryDef
    Dim TableA As Variant, wks As Workspace
    Set dbs = CurrentDb()

    Set wks = Workspaces(0)
         Set TableA = dbs.OpenRecordset("bkg_CARGO_booking_cx_ܼ", dbOpenSnapshot)    '򿪲ѯ



Do While TableA.EOF <> True  'ѭ

        StrDtn = "D:\BOOKING\" & TableA!VESSEL_NAME & " " & TableA!VOY & "_" & TableA!CARRIER_TRADE & "(" & Format(Date, "YYYYMMDD") & ").xls"   'Ŀļ
        FileCopy StrSor, StrDtn                           'ԴļĿļ
    Set xlApp = CreateObject("Excel.Application")         'ExcelӦó
    Set xlApp = New Excel.Application
        xlApp.Visible = True                              'ĿɼΪ桱


    Set xlBook = xlApp.Workbooks.Open(StrDtn)
    Set xlSheet = xlBook.Worksheets(1)                    'ѡSheet1




x = 10
vsl_id = TableA!VESSEL_NAME
voy_id = TableA!VOY
       
     '  Do Until TableA.EOF = True Or IsNull(TableA!VESSEL_NAME) Or TableA!VESSEL_NAME <> vsl_id Or TableA!VOY <> voy_id
       Do While TableA.EOF <> True And TableA!VESSEL_NAME = vsl_id And TableA!VOY = voy_id
        xlSheet.Cells(6, 2) = TableA!VESSEL_NAME
                xlSheet.Cells(6, 9) = TableA!VOY
                xlSheet.Cells(6, 18) = TableA!ETD
      
                
                xlSheet.Cells(x, 1) = TableA!۴
                xlSheet.Cells(x, 2) = TableA![L_20'GP]
                xlSheet.Cells(x, 3) = TableA![L_40'GP]
                xlSheet.Cells(x, 4) = TableA![L_40'HC]
                xlSheet.Cells(x, 5) = TableA![L_45'HC]
                xlSheet.Cells(x, 6) = TableA![L_20'RF]
                xlSheet.Cells(x, 7) = TableA![L_40'RH]
                xlSheet.Cells(x, 9) = TableA![L] / 1000

                xlSheet.Cells(x, 10) = TableA![T_20'GP]
                xlSheet.Cells(x, 11) = TableA![T_40'GP]
                xlSheet.Cells(x, 12) = TableA![T_40'HC]
                xlSheet.Cells(x, 13) = TableA![T_45'HC]
                xlSheet.Cells(x, 14) = TableA![T_20'RF]
                xlSheet.Cells(x, 15) = TableA![T_40'RH]
                xlSheet.Cells(x, 17) = TableA![T] / 1000

                x = x + 1
                TableA.MoveNext
                      If TableA.EOF = True Then
                Exit Do
                End If
          
            Loop
                
                'dbs.Close
                xlBook.Save
                xlApp.Quit
                Set xlApp = Nothing


Loop   'ѭ



'IPIԤ*****************************************************

        
    StrSor = "D:\DAILY_BOOKING_IPI.xls"

    Set dbs = CurrentDb()

    Set wks = Workspaces(0)
         Set TableA = dbs.OpenRecordset("bkg_CARGO_booking_IPI_CX_", dbOpenSnapshot)    '򿪲ѯ



Do While TableA.EOF <> True  'ѭ

        StrDtn = "D:\BOOKING\" & TableA!VESSEL_NAME & " " & TableA!VOY & "_" & TableA!CARRIER_TRADE & "_IPI_(" & Format(Date, "YYYYMMDD") & ").xls"   'Ŀļ
        FileCopy StrSor, StrDtn                           'ԴļĿļ
    Set xlApp = CreateObject("Excel.Application")         'ExcelӦó
    Set xlApp = New Excel.Application
        xlApp.Visible = True                              'ĿɼΪ桱


    Set xlBook = xlApp.Workbooks.Open(StrDtn)
    Set xlSheet = xlBook.Worksheets(1)                    'ѡSheet1




x = 5
vsl_id = TableA!VESSEL_NAME
voy_id = TableA!VOY
       
       Do While TableA.EOF <> True And TableA!VESSEL_NAME = vsl_id And TableA!VOY = voy_id
        xlSheet.Cells(3, 4) = TableA!VESSEL_NAME
                xlSheet.Cells(3, 8) = TableA!VOY
                'xlSheet.Cells(6, 16) = TableA!ETD
              X_ipi = "N"
                     Do Until x = 20
               If xlSheet.Cells(x, 1) = TableA![DEL_CODE] Then
                
                xlSheet.Cells(x, 2) = TableA![20'GP]
                xlSheet.Cells(x, 3) = TableA![40'GP]
                xlSheet.Cells(x, 4) = TableA![40'HC]
                xlSheet.Cells(x, 5) = TableA![45'HC]
                xlSheet.Cells(x, 6) = TableA![20'RF]
                xlSheet.Cells(x, 7) = TableA![40'RH]
             X_ipi = "Y" 'ģҵӦĸۿ
              End If
              x = x + 1
                      Loop
                x = 5
                If X_ipi = "N" Then
                MsgBox TableA!VESSEL_NAME & "  " & TableA!VOY & "   " & TableA!DEL_CODE & "IPIģûҵӦĸۿڣûд"
                End If
                TableA.MoveNext
                      If TableA.EOF = True Then
                        Exit Do
                      End If
          
            Loop
                
                'dbs.Close
                xlBook.Save
                xlApp.Quit
                Set xlApp = Nothing


Loop   'ѭ



MsgBox "ϣD:\BOOKING\"