View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Merge several fixed width text files into one

Thanks a Lot Jim for the quick Reply.

In some site, they adapted your code to relatives paths this way:

---
Dim r As String
r = Application.ThisWorkbook.Path
Dim SrcFiles, CurrSrc As String
Dim DestFile As String, Counter As Integer
Dim TextLine As String
SrcFiles = Array(r & "\File1.txt", r & "\File2.txt")
Open r & "\File3.txt" For Output As #1
For Counter = 0 To UBound(SrcFiles)
Open SrcFiles(Counter) For Input As #2
Do While Not EOF(2)
Line Input #2, TextLine
Print #1, TextLine
Loop
Close #2
Next
Close #1

---


But As i told you, the file 3 doesn't append the text, just create a new one
every time the code is ejecuted.

Som help would be great.

Also, I've note that actually, the "CurrSrc" and "DestFile" variables are
declared but not used at all, they can be "erased" from the code?


I'm not Jim! I don't see how this code will do what you want, NOR do I see any
point *spending* the energy required to rewrite a solution that will work (I
have Lou Gehrig's) when the already existing free utility I posted a link to
does an excellent job of merging text files.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion