VBA code :
Sub Append_Text_Files()
Dim oFS As FileSystemObject
Dim oFS1 As FileSystemObject
Dim oTS As TextStream
Dim oTS1 As TextStream
Dim vTemp
Set oFS = New FileSystemObject
Set oFS1 = New FileSystemObject
For i1 = 1 To 3
Set oTS = oFS.OpenTextFile(ActiveWorkbook.Path & "\" & "Doc" & i1 & ".txt", ForReading)
vTemp = oTS.ReadAll
Set oTS1 = oFS.OpenTextFile(ActiveWorkbook.Path & "\" & "Output.txt", ForAppending, True)
oTS1.Write (vTemp)
oTS1.Close
oTS.Close
Next i1
End Sub
上面的程式碼 : 將 Doc1.txt 加 Doc2.txt 加 Doc3.txt , 合成 新檔 "Output.txt"
沒有留言:
張貼留言