|
- Option Explicit
- Public Sub ImportCombine_Step1_Main()
- Dim dtStartTime As Date
- Dim dtEndTime As Date
- Dim myWkb As Workbook
- Dim wkb_EachSubFile As Workbook
- Dim wks_EachSubFileSheet1 As Worksheet
- Dim sEachSubFileName As String
- Dim arr_AllFileNames As Variant
- Dim iLoop As Long
- Dim iProcessedFile As Long
-
- '/ initial
- dtStartTime = Now
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set myWkb = ThisWorkbook
- Call InitialLog
- '/ check input file folder
- If CheckFolderFile(sInput1_FolderPath) = False Then
- Exit Sub
- End If
- '/ Get folder files
- arr_AllFileNames = GetFilesName(sInput1_FolderPath)
- For iLoop = 0 To UBound(arr_AllFileNames)
- sEachSubFileName = sInput1_FolderPath & "" & arr_AllFileNames(iLoop)
- Application.AskToUpdateLinks = False
- Set wkb_EachSubFile = Workbooks.Open(sEachSubFileName, False)
- Select Case iType
- Case 1 '/ D365
- '/ process Each Folder File
- If GetData_D365(wkb_EachSubFile) = True Then
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine OK")
- iProcessedFile = iProcessedFile + 1
- Else
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine Error")
- End If
- wkb_EachSubFile.Close SaveChanges:=False
- Set wkb_EachSubFile = Nothing
- Case 2 '/ Zhao hang
- '/ process Each Folder File
- If GetData_CMB(wkb_EachSubFile) = True Then
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine OK")
- iProcessedFile = iProcessedFile + 1
- Else
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine Error")
- End If
- wkb_EachSubFile.Close SaveChanges:=False
- Set wkb_EachSubFile = Nothing
- Case 3 '/ hua qi
- '/ process Each Folder File
- If GetData_CitiBank(wkb_EachSubFile) = True Then
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine OK")
- iProcessedFile = iProcessedFile + 1
- Else
- Call WriteDataToLog("File [" & arr_AllFileNames(iLoop) & " ]", "Combine Error")
- End If
- wkb_EachSubFile.Close SaveChanges:=False
- Set wkb_EachSubFile = Nothing
- End Select
- Next
- '/ end
- With Application
- .ScreenUpdating = True
- .DisplayAlerts = True
- End With
- dtEndTime = Now
- Call WriteDataToLog("Combine Process Completed.", "OK")
- Call ShowMsgbox("Combine Processing Completed, Please Check it." & vbCrLf & vbCrLf & _
- "Process Combine Files Count [ " & iProcessedFile & " ]" & vbCrLf & vbCrLf & _
- "Processing Time : [ " & TimeDiff(dtStartTime, dtEndTime) & " ]", 1)
- Exit Sub
- ErrorHandle:
- MsgBox "Error [ PaymentCheck_Step1_Main ]", vbExclamation, "Error"
- End Sub
- Public Sub EmptyTemplateSheet()
- Dim myWkb As Workbook
-
- Set myWkb = ThisWorkbook
- '/ initial Combine sheet data
- With myWkb.Worksheets("TemplateSheet")
- .AutoFilterMode = False
- .Columns("A:AZ").Hidden = False
- .Range("A2:Z1048576").Delete
- End With
- Call ShowMsgbox("TemplateSheet Data Empty OK.", 1)
- End Sub
- Public Sub GetLoadTitle(ByVal strType As String)
- Dim myWkb As Workbook
- Dim iLastRow As Long
- Dim iLoop As Long
- Dim myMappingSheet As Worksheet
-
- Set myWkb = ThisWorkbook
- Set myMappingSheet = myWkb.Worksheets("Mapping")
- Set dic_LoadTitle = CreateObject("Scripting.dictionary")
- With myMappingSheet
- .AutoFilterMode = False
- .Range("A:AZ").EntireColumn.Hidden = False
- iLastRow = .Range("A65536").End(xlUp).Row
- Select Case strType
- Case "D365"
- For iLoop = 2 To iLastRow
- If .Cells(iLoop, "A").Value <> "" And .Cells(iLoop, "C").Value <> "" Then
- dic_LoadTitle(.Cells(iLoop, "C").Value) = .Cells(iLoop, "A").Value
- End If
- Next
- Case "CitiBank"
- For iLoop = 2 To iLastRow
- If .Cells(iLoop, "A").Value <> "" And .Cells(iLoop, "D").Value <> "" Then
- dic_LoadTitle(.Cells(iLoop, "D").Value) = .Cells(iLoop, "A").Value
- End If
- Next
- Case "CMB"
- For iLoop = 4 To iLastRow
- If .Cells(iLoop, "A").Value <> "" And .Cells(iLoop, "E").Value <> "" Then
- dic_LoadTitle(.Cells(iLoop, "E").Value) = .Cells(iLoop, "A").Value
- End If
- Next
- End Select
- End With
- End Sub
复制代码
|
|