通勤認定エクセルツール対応14
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
Attribute VB_Name = "Common_Button"
|
||||
Option Explicit
|
||||
|
||||
' --- Public Variables ---
|
||||
Public lastErrorMsg As String
|
||||
' --- Private Variables ---
|
||||
Private m_LastErrorMsg As String
|
||||
|
||||
' ============================================================
|
||||
' Get/Set last error message
|
||||
' ============================================================
|
||||
Public Sub SetLastErrorMsg(msg As String)
|
||||
m_LastErrorMsg = msg
|
||||
End Sub
|
||||
|
||||
Public Function GetLastErrorMsg() As String
|
||||
GetLastErrorMsg = m_LastErrorMsg
|
||||
End Function
|
||||
|
||||
Public Sub ClearLastErrorMsg()
|
||||
m_LastErrorMsg = ""
|
||||
End Sub
|
||||
|
||||
' ============================================================
|
||||
' Module Name: Common_Button
|
||||
@@ -67,6 +82,7 @@ Sub RefreshCache_Button()
|
||||
Exit Sub
|
||||
|
||||
ErrorHandler:
|
||||
Debug.Print "sheetName = " & sheetName
|
||||
HandleError "RefreshCache_Button"
|
||||
End Sub
|
||||
|
||||
@@ -373,10 +389,10 @@ Public Function RunValidationSilent(ws As Worksheet) As Long
|
||||
Dim r As Long
|
||||
Dim hasError As Boolean: hasError = False
|
||||
For r = startRow To lastDataRow
|
||||
lastErrorMsg = ""
|
||||
Application.Run validate, ws, r, lastDataRow
|
||||
If lastErrorMsg <> "" Then
|
||||
Err.Raise ERR_VALIDATION_FAILED, "RunValidationSilent", lastErrorMsg
|
||||
SetLastErrorMsg ""
|
||||
Application.Run validate, ws, r, lastDataRow
|
||||
If GetLastErrorMsg() <> "" Then
|
||||
Err.Raise ERR_VALIDATION_FAILED, "RunValidationSilent", GetLastErrorMsg()
|
||||
End If
|
||||
Dim errorMessage As String: errorMessage = Trim(ws.Cells(r, errorCol).Value)
|
||||
Dim errorCode As String: errorCode = GetCode(errorMessage)
|
||||
|
||||
@@ -52,8 +52,8 @@ Sub WriteCSVFromArray( _
|
||||
If rows = 0 Or cols = 0 Then Exit Sub ' Empty array, exit early
|
||||
|
||||
' === Build CSV content ===
|
||||
Dim outputLines As Collection
|
||||
Set outputLines = New Collection
|
||||
Dim outputLines As VBA.Collection
|
||||
Set outputLines = New VBA.Collection
|
||||
|
||||
Dim i As Long, j As Long
|
||||
Dim rowStr As String
|
||||
@@ -129,8 +129,8 @@ ExitPoint:
|
||||
ArrayDimensions = dimCount - 1
|
||||
End Function
|
||||
|
||||
' Helper function: convert a Collection to a 1D array (for use with Join)
|
||||
Private Function CollectionToArray(col As Collection) As Variant
|
||||
' Helper function: convert a VBA.Collection to a 1D array (for use with Join)
|
||||
Private Function CollectionToArray(col As VBA.Collection) As Variant
|
||||
If col.Count = 0 Then
|
||||
CollectionToArray = Array()
|
||||
Exit Function
|
||||
@@ -210,7 +210,7 @@ Function ReadCSVAs2DArrayStrict( _
|
||||
textContent = Replace(textContent, vbCr, vbLf)
|
||||
|
||||
' === transfer into collection ===
|
||||
Dim lines As Collection
|
||||
Dim lines As VBA.Collection
|
||||
Set lines = ParseCSVLines(textContent)
|
||||
|
||||
' === validate empty ===
|
||||
@@ -259,14 +259,14 @@ Function ReadCSVAs2DArrayStrict( _
|
||||
End Function
|
||||
|
||||
' Helper function: Parse CSV text into collection of string arrays (zero-based per row)
|
||||
Private Function ParseCSVLines(ByVal csvText As String) As Collection
|
||||
Set ParseCSVLines = New Collection
|
||||
Private Function ParseCSVLines(ByVal csvText As String) As VBA.Collection
|
||||
Set ParseCSVLines = New VBA.Collection
|
||||
Dim length As Long: length = Len(csvText)
|
||||
If length = 0 Then Exit Function
|
||||
|
||||
Dim i As Long: i = 1
|
||||
Dim currentField As String
|
||||
Dim currentRow As Collection: Set currentRow = New Collection
|
||||
Dim currentRow As VBA.Collection: Set currentRow = New VBA.Collection
|
||||
Dim inQuotes As Boolean
|
||||
Dim c As String
|
||||
|
||||
@@ -314,7 +314,7 @@ Private Function ParseCSVLines(ByVal csvText As String) As Collection
|
||||
Next k
|
||||
End If
|
||||
ParseCSVLines.Add arr
|
||||
Set currentRow = New Collection
|
||||
Set currentRow = New VBA.Collection
|
||||
currentField = ""
|
||||
inQuotes = False
|
||||
i = i + 1
|
||||
|
||||
@@ -429,6 +429,11 @@ Function ColLetter(colNum As Long) As String
|
||||
ColLetter = Split(Cells(1, colNum).Address, "$")(1)
|
||||
End Function
|
||||
|
||||
'Convert column letter to number
|
||||
Function ColNum(colLetter As String) As Long
|
||||
ColNum = Range(colLetter & "1").Column
|
||||
End Function
|
||||
|
||||
'Check required field is not empty
|
||||
Function CheckRequired(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal errorCol As String) As Boolean
|
||||
Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Attribute VB_Name = "ValidationRuleEnums"
|
||||
' ValidationRuleEnums.bas
|
||||
' Standard module for shared rule-type constants.
|
||||
' Using Long constants instead of Enum to avoid VBA class-module ambiguity issues.
|
||||
Option Explicit
|
||||
|
||||
Public Const ValRule_Required As Long = 0
|
||||
Public Const ValRule_Date As Long = 1
|
||||
Public Const ValRule_Number As Long = 2
|
||||
Public Const ValRule_CodeSelect As Long = 3
|
||||
Public Const ValRule_Range As Long = 4
|
||||
Public Const ValRule_Duplicate As Long = 5
|
||||
Public Const ValRule_Char As Long = 6
|
||||
Public Const ValRule_Varchar As Long = 7
|
||||
Public Const ValRule_Check01 As Long = 8
|
||||
Public Const ValRule_Alphanumeric As Long = 9
|
||||
Public Const ValRule_Custom As Long = 11
|
||||
Reference in New Issue
Block a user