text file consolidation RRS feed

  • Question

  • this works for the task of initially consolidating separate text files (Input1, Input2,) into one (Final.txt)


    Open "c:\FolderA\Final.txt" For Output As #3 ' creates new blank file for putting info into below


    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

    Set oTS = oFS.OpenTextFile("c:\FolderA\Input1.txt", ForReading)

    vTemp = oTS.ReadAll

    Set oTS1 = oFS.OpenTextFile("c:\FolderA\Final.txt", ForAppending, True)

    oTS1.Write (vTemp)


    Set oTS = oFS.OpenTextFile("c:\FolderA\Input2.txt", ForReading)

    vTemp = oTS.ReadAll

    oTS1.Write (vTemp)


    so far so good.....when this code runs the inspection of Final.txt is fine..

    but am now needing to add some more code as further down in the logic there may be different Input text files that should instead be used (not appended) and so there is the need to start over.  This is my question - as I have run into a variety of permission denied and invalid attempts to kill or close.... which has me stumped.....

    Thursday, February 19, 2015 12:26 AM