feat: D7切替を廃止しExport/Get両方を毎回実行、出力先をtableId+E/Gシートに分離
D7による方式切替をやめ、run()実行のたびにExport方式・Get方式を両方実行するよう変更。 Export結果は tableId&"E" シート、Get結果は tableId&"G" シートへ別々に保存。 両シートが分かれたため、Get→Export切替時のヘッダ残留対策(既存テーブル削除)は不要になり削除。 処理時間はD4〜D6に両方式合計で記録。
This commit is contained in:
parent
2192c9718f
commit
81c9f67331
@ -6,7 +6,6 @@ Public baseURL As String
|
|||||||
Public yearFilter As String
|
Public yearFilter As String
|
||||||
Public tableId As String
|
Public tableId As String
|
||||||
Public defaultSh As Worksheet
|
Public defaultSh As Worksheet
|
||||||
Public fetchMethod As String
|
|
||||||
|
|
||||||
Function init()
|
Function init()
|
||||||
'Pleasanter API KEY
|
'Pleasanter API KEY
|
||||||
@ -15,7 +14,6 @@ Function init()
|
|||||||
tableId = Range("着工要因ID")
|
tableId = Range("着工要因ID")
|
||||||
|
|
||||||
Set defaultSh = ThisWorkbook.Sheets("基本情報")
|
Set defaultSh = ThisWorkbook.Sheets("基本情報")
|
||||||
fetchMethod = defaultSh.Range("D7").Value
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
'******************************************************************************
|
'******************************************************************************
|
||||||
@ -32,13 +30,10 @@ Sub run()
|
|||||||
'------------------------------------------
|
'------------------------------------------
|
||||||
Debug.Print "処理開始"
|
Debug.Print "処理開始"
|
||||||
|
|
||||||
Dim success As Boolean
|
Dim exportSuccess As Boolean
|
||||||
Select Case fetchMethod
|
Dim getSuccess As Boolean
|
||||||
Case "Get"
|
exportSuccess = runExportFlow()
|
||||||
success = runGetFlow()
|
getSuccess = runGetFlow()
|
||||||
Case Else
|
|
||||||
success = runExportFlow()
|
|
||||||
End Select
|
|
||||||
|
|
||||||
Debug.Print "処理終了"
|
Debug.Print "処理終了"
|
||||||
'------------------------------------------
|
'------------------------------------------
|
||||||
@ -52,7 +47,7 @@ Cleanup:
|
|||||||
If Err.Number <> 0 Then
|
If Err.Number <> 0 Then
|
||||||
defaultSh.Range("D3").Value = "取込処理失敗(エラー): " & Err.Description
|
defaultSh.Range("D3").Value = "取込処理失敗(エラー): " & Err.Description
|
||||||
Err.Clear
|
Err.Clear
|
||||||
ElseIf Not success Then
|
ElseIf Not (exportSuccess And getSuccess) Then
|
||||||
defaultSh.Range("D3").Value = "取込処理失敗(データ取得エラー)"
|
defaultSh.Range("D3").Value = "取込処理失敗(データ取得エラー)"
|
||||||
Else
|
Else
|
||||||
defaultSh.Range("D3").Value = "取込処理完了"
|
defaultSh.Range("D3").Value = "取込処理完了"
|
||||||
@ -72,12 +67,7 @@ Function runExportFlow() As Boolean
|
|||||||
Debug.Print "データが取得できませんでした"
|
Debug.Print "データが取得できませんでした"
|
||||||
runExportFlow = False
|
runExportFlow = False
|
||||||
Else
|
Else
|
||||||
'Get方式実行時のヘッダ列構成が残っている場合に備え、既存テーブルを削除してから作り直す
|
Call exportCSVDataToSheet(resData, tableId & "E")
|
||||||
On Error Resume Next
|
|
||||||
ThisWorkbook.Sheets(tableId).ListObjects(tableId).Delete
|
|
||||||
On Error GoTo 0
|
|
||||||
|
|
||||||
Call exportCSVDataToSheet(resData, tableId)
|
|
||||||
runExportFlow = True
|
runExportFlow = True
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
@ -98,7 +88,7 @@ Function runGetFlow() As Boolean
|
|||||||
Debug.Print "データが取得できませんでした"
|
Debug.Print "データが取得できませんでした"
|
||||||
runGetFlow = False
|
runGetFlow = False
|
||||||
Else
|
Else
|
||||||
Call getRecordsDataToSheet(records, tableId)
|
Call getRecordsDataToSheet(records, tableId & "G")
|
||||||
runGetFlow = True
|
runGetFlow = True
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user