目次 |
---|
・ファイル読み込み ・Line Input ・ファイル内容をエクセルシートに書き出し |
Inf = FreeFile Open "c:¥tools¥a.txt" For Input As #Infこれでa.txtというファイルを入力モードで操作できるようになります。
Inf = FreeFile Open "c:¥tools¥a.txt" For Input As #Inf Do Until EOF(Inf) LoopEOF関数の引数にはファイル番号を指定し、Do Untilと併用します。EOF関数はファイルの終わりになるとTrueを返し、それ以外はFalseを返す関数です。
Dim Str As String Inf = FreeFile Open "c:¥tools¥a.txt" For Input As #Inf Do Until EOF(Inf) Line Input #Inf, Str MsgBox Str Loop
Dim Str As String Sheets("作業シート").Activate '作業シートをアクティブ Cells.Clear '作業シートクリア Range("A1").Select 'A1をセレクト Line = 1 '行 inf = FreeFile Open "c:¥tools¥a.txt" For Input As #inf Do Until EOF(inf) Line Input #inf, Str Cells(Line, 1) = Str Line = Line + 1 Loop