2012/10/10

VBAにおけるファイルアクセスについて


Dim intFileNo as Integer
Dim strBuffer as String
Dim intRows as Integer

'' ファイル番号を取得
intFileNo = FreeFile

'' ファイルオープン
Open "ファイルパス" For Input As #intFileNo
   
'' ファイルのEOF(End of File)まで繰り返す
Do Until EOF(intFileNo)

  '' 1行読み込み
  Line Input #intFileNo, strBuffer
           
  ''行を加算
  intRows = intRows + 1
 
  '' A列にレコード内容を表示
  Cells(intRows, 1).Value = strBuffer
Loop

'' ファイルクローズ    
Close #intFileNo

0 件のコメント: