Jun 19, 2002 #1 tumor Programmer May 2, 2002 7 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 May 12, 2000 1,317 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