'-------------------------------------------------------------------------------
' 【関 数 名】テキストファイル読み込み
' 【処理概要】テキストファイルを読み込み、Excelシートに1行ずつ
' 【引 数】[I] ByVal txtFilePath As String テキストファイルパス
' [I] ByVal sh As Worksheet 出力先ワークシートオブジェクト
' [I] ByVal cellAddress As String 出力先行インデックス
' 【戻 り 値】なし
'-------------------------------------------------------------------------------
Public Sub loadTextFileToXlsSheet( _
ByVal txtFilePath As String, ByVal sh As Worksheet, _
ByVal cellAddress As String)
Dim fn As Integer 'ファイルナンバー
Dim buf As String '作業領域
Dim rowIndex As Long
Dim colIndex As Long
rowIndex = sh.Range(cellAddress).Row
colIndex = sh.Range(cellAddress).Column
fn = FreeFile
Open txtFilePath For Input As #fn
Do Until EOF(fn)
Line Input #fn, buf
With sh.Cells(rowIndex, colIndex)
.NumberFormat = "@"
.value = buf
End With
rowIndex = rowIndex + 1
Loop
Close #fn
End Sub