' You can create a function that receives three file names.
' Needs References to Microsoft Scripting Runtime
' Merge two text files
fHeader = "C:\MyHeaderFile.csv"
fData = "C:\MyDataFile.csv"
fOut = "C:\NewFile.csv"
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile(fOut)
Set objTextFile = objFSO.OpenTextFile(fHeader, ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine strText
Set objTextFile = objFSO.OpenTextFile(fData & " ", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine strText
objOutputFile.Close
Samples of VBA code I'm using in my daily tasks.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment