==[[Excel VBA シートを設定ファイルとして利用する]]==
[[Excel VBA]] |
Private Const COL_VAR_KEY COL_VA[[R]]_KEY As Integer = 1 Private Const COL_VAR_VAL COL_VA[[R]]_VAL As Integer = 2
Private properties As Object
Public Sub test()
Call loadProperties
Debug.Print properties.Item("BASE_DIRBASE_DI[[R]]")
End Sub
'
' Excelの[[Excel]]の"設定"シートから、値を読込みMapに格納する
' 1列目:KEY、2列目:値
'
Private Sub loadProperties()
Dim sheet As Worksheet
Dim endCel As Range[[R]]ange Dim eRow e[[R]]ow As Long
Dim r As Long
Set sheet = ActiveWorkbook.Sheets("設定")
Set endCel = sheet.Range[[R]]ange("A1").SpecialCells(xlLastCell)
For r = 1 To endCel.Row[[R]]ow
Call properties.Add( _
sheet.Cells(r, COL_VAR_KEYCOL_VA[[R]]_KEY).Text _ , sheet.Cells(r, COL_VAR_VALCOL_VA[[R]]_VAL).Text)
Next
End Sub