20260515指摘対応

This commit is contained in:
guanxiangwei
2026-05-15 15:13:00 +09:00
parent 69b940867e
commit 5930d49cf2
18 changed files with 213 additions and 30 deletions

View File

@@ -6,8 +6,8 @@ Sub ImportModulesAndSheets_Safe()
Set fso = CreateObject("Scripting.FileSystemObject")
Const PROJECT_PATH As String = "D:\Project\upds7\vba\"
Const MODULE_PATH As String = PROJECT_PATH & "src\module"
Const SHEET_PATH As String = PROJECT_PATH & "src\sheet"
Const MODULE_PATH As String = PROJECT_PATH & "src\sh\tuk\module"
Const SHEET_PATH As String = PROJECT_PATH & "src\sh\tuk\sheet"
' --- Phase 1: Validation ---
Debug.Print "[LOG] Starting validation phase..."

View File

@@ -141,6 +141,8 @@ Private Sub Do_Validation(ws As Excel.Worksheet)
MsgBox "Validation complete. Errors: 0", vbInformation
End If
Do_Fit ws
Exit Sub
ErrorHandler:
@@ -288,7 +290,8 @@ Private Sub Do_Fit(ws As Excel.Worksheet)
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()
Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName)
Dim startCol As String: startCol = sheetConf("StartCol")
' 2026-05-15 adjust width function contains error column
Dim startCol As String: startCol = sheetConf("ErrorCol")
Dim endCol As String: endCol = sheetConf("EndCol")
ws.Columns(startCol & ":" & endCol).AutoFit

View File

@@ -313,17 +313,21 @@ Function CheckHeaderEdit(ByVal ws As Worksheet, ByVal Target As Range) As Boolea
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()
Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName)
Dim headerRow As Long: headerRow = sheetConf("HeaderRow")
Dim filterRow As Long: filterRow = sheetConf("FilterRow")
' Check header row (headerRow) cannot be edited
If Target.Row = headerRow Then
Application.EnableEvents = False
MsgBox "Header row can not be edit", vbExclamation
Application.Undo
Application.EnableEvents = True
Dim r As Long
For r = Target.Row To Target.Row + Target.Rows.Count - 1
If r = headerRow Or r = filterRow Then
Application.EnableEvents = False
MsgBox "Header or type definition row cannot be edited.", vbExclamation
Application.Undo
Application.EnableEvents = True
CheckHeaderEdit = True
Exit Function
End If
CheckHeaderEdit = True
Exit Function
End If
Next r
CheckHeaderEdit = False
End Function

View File

@@ -305,7 +305,7 @@ Private Sub RefreshSheetDict()
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "BC"
sheetConf("ErrorCol") = "BD"
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 8
sheetConf("HeaderRow") = 6
sheetConf("CSV_Encoding") = "shift_jis"
@@ -321,7 +321,7 @@ Private Sub RefreshSheetDict()
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "N"
sheetConf("ErrorCol") = "O"
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 7
sheetConf("HeaderRow") = 5
sheetConf("CacheName") = "m1Cache"
@@ -340,15 +340,15 @@ Private Sub RefreshSheetDict()
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "R"
sheetConf("ErrorCol") = "S"
sheetConf("StartRow") = 7
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 8
sheetConf("HeaderRow") = 6
sheetConf("CSV_Encoding") = "shift_jis"
sheetConf("HasHeader") = True
sheetConf("ExpectedColumnCount") = 11
sheetConf("HeaderColumns") = Array("C", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R")
sheetConf("AlwaysQuote") = False
sheetConf("FilterRow") = 6
sheetConf("FilterRow") = 7
Set sheetConfDict("M2") = sheetConf
Debug.Print "RefreshSheetDict M2 ok."
@@ -482,11 +482,11 @@ Private Sub RefreshSheetDict()
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "F"
sheetConf("ErrorCol") = ""
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 6
sheetConf("HeaderRow") = ""
sheetConf("CSV_Encoding") = "utf-8"
sheetConf("HasHeader") = False
sheetConf("HeaderRow") = "5"
sheetConf("CSV_Encoding") = "shift_jis"
sheetConf("HasHeader") = True
sheetConf("ExpectedColumnCount") = 4
sheetConf("HeaderColumns") = Array("C", "D", "E", "F")
sheetConf("AlwaysQuote") = True
@@ -498,9 +498,9 @@ Private Sub RefreshSheetDict()
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "O"
sheetConf("ErrorCol") = ""
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 6
sheetConf("HeaderRow") = ""
sheetConf("HeaderRow") = "5"
sheetConf("CSV_Encoding") = "utf-8"
sheetConf("HasHeader") = False
sheetConf("ExpectedColumnCount") = 13

View File

@@ -2,4 +2,14 @@
' Module Name: Master_address
' Module Desc: O1 address master data management
' Module Methods:
' - Worksheet_Change
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub

View File

@@ -2,5 +2,14 @@
' Module Name: Master_507
' Module Desc: O2 master data management (507)
' Module Methods:
' - Worksheet_Change
' ============================================================
' ====== (507) =======
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub

View File

@@ -2,8 +2,19 @@
' Module Name: Master_244
' Module Desc: T1 master data management (244)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)

View File

@@ -2,8 +2,19 @@
' Module Name: Master_245
' Module Desc: T2 master data management (245)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)

View File

@@ -2,8 +2,19 @@
' Module Name: Master_246
' Module Desc: T3 master data management (246)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)

View File

@@ -2,8 +2,19 @@
' Module Name: Master_222
' Module Desc: Z1 master data management (222)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)

View File

@@ -2,8 +2,19 @@
' Module Name: Master_223
' Module Desc: Z2 master data management (223)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)

View File

@@ -2,8 +2,19 @@
' Module Name: Master_Z3_224
' Module Desc: Z3 master data management (224)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()

View File

@@ -2,8 +2,19 @@
' Module Name: Master_Z4_220
' Module Desc: Z4 master data management (220)
' Module Methods:
' - Worksheet_Change
' - Validate
' ============================================================
' ============================================================
' Event Handlers
' ============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
If HasHeaderEdit = True Then Exit Sub
End Sub
'
Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long)
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()