Jun 19, 2002 #1 tumor Programmer Joined May 2, 2002 Messages 7 Location US I would like to know if its possible to open multiple files from one folder and add the contents of the file to the same file. say each file has different numbers in it and i want to add those numbers and save them to one file
I would like to know if its possible to open multiple files from one folder and add the contents of the file to the same file. say each file has different numbers in it and i want to add those numbers and save them to one file
Jun 20, 2002 #2 jonscott8 Programmer Joined May 12, 2000 Messages 1,317 Location US Set oFSO = CreateObject("Scripting.FileSystemObject" Set oFile = oFSO.OpenTextFile("C:\file1.txt",1) nVar = CDbl(oFile.ReadAll) oFile.Close Set oFile = oFSO.OpenTextFile("C:\file2.txt",1) nVar = nVar + CDbl(oFile.ReadAll) oFile.Close Set oFile = oFSO.OpenTextFile("C:\file3.txt",2,True) oFile.WriteLine nVar oFile.Close Set oFile = Nothing Set oFSO = Nothing Jon Hawkins Upvote 0 Downvote
Set oFSO = CreateObject("Scripting.FileSystemObject" Set oFile = oFSO.OpenTextFile("C:\file1.txt",1) nVar = CDbl(oFile.ReadAll) oFile.Close Set oFile = oFSO.OpenTextFile("C:\file2.txt",1) nVar = nVar + CDbl(oFile.ReadAll) oFile.Close Set oFile = oFSO.OpenTextFile("C:\file3.txt",2,True) oFile.WriteLine nVar oFile.Close Set oFile = Nothing Set oFSO = Nothing Jon Hawkins