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:
Kenichiro NOGI 2026-09-11 14:20:30 +09:00
parent 2192c9718f
commit 81c9f67331

View File

@ -6,7 +6,6 @@ Public baseURL As String
Public yearFilter As String
Public tableId As String
Public defaultSh As Worksheet
Public fetchMethod As String
Function init()
'Pleasanter API KEY
@ -15,7 +14,6 @@ Function init()
tableId = Range("着工要因ID")
Set defaultSh = ThisWorkbook.Sheets("基本情報")
fetchMethod = defaultSh.Range("D7").Value
End Function
'******************************************************************************
@ -32,13 +30,10 @@ Sub run()
'------------------------------------------
Debug.Print "処理開始"
Dim success As Boolean
Select Case fetchMethod
Case "Get"
success = runGetFlow()
Case Else
success = runExportFlow()
End Select
Dim exportSuccess As Boolean
Dim getSuccess As Boolean
exportSuccess = runExportFlow()
getSuccess = runGetFlow()
Debug.Print "処理終了"
'------------------------------------------
@ -52,7 +47,7 @@ Cleanup:
If Err.Number <> 0 Then
defaultSh.Range("D3").Value = "取込処理失敗(エラー): " & Err.Description
Err.Clear
ElseIf Not success Then
ElseIf Not (exportSuccess And getSuccess) Then
defaultSh.Range("D3").Value = "取込処理失敗(データ取得エラー)"
Else
defaultSh.Range("D3").Value = "取込処理完了"
@ -72,12 +67,7 @@ Function runExportFlow() As Boolean
Debug.Print "データが取得できませんでした"
runExportFlow = False
Else
'Get方式実行時のヘッダ列構成が残っている場合に備え、既存テーブルを削除してから作り直す
On Error Resume Next
ThisWorkbook.Sheets(tableId).ListObjects(tableId).Delete
On Error GoTo 0
Call exportCSVDataToSheet(resData, tableId)
Call exportCSVDataToSheet(resData, tableId & "E")
runExportFlow = True
End If
End Function
@ -98,7 +88,7 @@ Function runGetFlow() As Boolean
Debug.Print "データが取得できませんでした"
runGetFlow = False
Else
Call getRecordsDataToSheet(records, tableId)
Call getRecordsDataToSheet(records, tableId & "G")
runGetFlow = True
End If
End Function