アットウィキロゴ

vba04

Sub 複写置換()
    
    Dim n As Integer
    Dim strFILE, strREC As String
    
    n = 2
    Do While Cells(n, 2).Value <> ""

        strFILE = Dir(Cells(n, 2) & "\" & Cells(n, 3), vbNormal)
        Do While strFILE <> ""

            ' 指定ファイルをOPEN(入力モード)
            Open Cells(n, 2) & "\" & strFILE For Input As #1

            ' 指定ファイルをOPEN(出力モード)
            Open Cells(n, 4) & "\" & strFILE For Output As #2

            ' ファイルのEOF(End of File)まで繰り返す
            Do Until EOF(1)
                Line Input #1, strREC
                strREC = Replace(strREC, Cells(n, 5), Cells(n, 6), , , vbBinaryCompare)
                Print #2, strREC
            Loop
            Close
            strFILE = Dir()
        Loop
        n = n + 1
    Loop
End Sub
最終更新:2013年04月19日 00:40