Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
On my Userform, I am using the listbox to populate it with files from a
directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
http://www.rondebruin.nl/copy3.htm
-- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
This site is and will be very helpful in the near future in another segment
of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
You mean the listbox has a list of fully qualified filenames for text files
which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
the listbox has a list of fully qualified filenames for text files
which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Assumes the Listbox is from the control toolbox toolbar and is on the
activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Entering in the Code, when running the module the following error "Object
doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Here is an example from the immediate window demonstrating it working
perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
I understand the problem now. The problem is I am on a Userform instead of an
active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Sub AppendFiles1()
Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Running the module it is debugging to the line "If Dir(SrcName) < "" Then"
then it exits. and the only thing created is an empty file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Code is tested and runs without a hitch for me. xl2003
even if SrcName were empty, that line won't raise an error: Demo'd from the immediate window: ? dir("") < "" True Now if SrcName = "some non existent path" You will get a 52 error or similar. Nothing I can do about it if you have bad data in your listbox. -- Regards, Tom Oglvy "Larry" wrote in message ... Running the module it is debugging to the line "If Dir(SrcName) < "" Then" then it exits. and the only thing created is an empty file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm -- Regards, Tom Ogilvy "Larry" wrote in message ... On my Userform, I am using the listbox to populate it with files from a directory. What I am trying to do is open the files and merge them into a single file. I appreciate any help anyone can give me. -- Larry E. Brueshaber |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
In merging the files, were they delimited. I am trying to figure out if that
is the problem. I am enclosing an example of a file that I am using: "DI554K",2103,525,0,"€¦.",5,1222,200637,0,999948, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,999940, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,999939, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,870185, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,999938, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,832338, 1,0,2 "DI554K",2103,525,0,"€¦.",5,1222,200637,0,1060,1, 0,2 -- Larry E. Brueshaber "Tom Ogilvy" wrote: Code is tested and runs without a hitch for me. xl2003 even if SrcName were empty, that line won't raise an error: Demo'd from the immediate window: ? dir("") < "" True Now if SrcName = "some non existent path" You will get a 52 error or similar. Nothing I can do about it if you have bad data in your listbox. -- Regards, Tom Oglvy "Larry" wrote in message ... Running the module it is debugging to the line "If Dir(SrcName) < "" Then" then it exits. and the only thing created is an empty file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
No. Where you say it errors would indicate the filename is bad. Line
Input reads an entire line. delimiters are meaningless to it. -- Regards, Tom Ogilvy "Larry" wrote in message ... In merging the files, were they delimited. I am trying to figure out if that is the problem. I am enclosing an example of a file that I am using: "DI554K",2103,525,0,"..",5,1222,200637,0,999948,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999940,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999939,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,870185,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999938,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,832338,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,1060,1,0, 2 -- Larry E. Brueshaber "Tom Ogilvy" wrote: Code is tested and runs without a hitch for me. xl2003 even if SrcName were empty, that line won't raise an error: Demo'd from the immediate window: ? dir("") < "" True Now if SrcName = "some non existent path" You will get a 52 error or similar. Nothing I can do about it if you have bad data in your listbox. -- Regards, Tom Oglvy "Larry" wrote in message ... Running the module it is debugging to the line "If Dir(SrcName) < "" Then" then it exits. and the only thing created is an empty file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for text files which you want to combine into one large file? Or have you read each file into the listbox sequentially (so the data from all files is in the listbox) and you want to write the list back out to a textfile? -- Regards, Tom Ogilvy "Larry" wrote in message ... This site is and will be very helpful in the near future in another segment of The program I am writing; right now I have a populated listbox with txt files and I am trying to merge them into another text file. I appreciate all the help so far. -- Larry E. Brueshaber "Tom Ogilvy" wrote: http://www.rondebruin.nl/copy3.htm |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merging Files in ListView
Thank you for all your support, I appreciate it very much. I did a file
check and I can see the problem now, I need to go back and redo the save routine. I will be glad to go back to Visual Basic; The more I dwell into Excel (VBA) it seems there pops up 100 things I don't know about it. Again, thank you for your support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: No. Where you say it errors would indicate the filename is bad. Line Input reads an entire line. delimiters are meaningless to it. -- Regards, Tom Ogilvy "Larry" wrote in message ... In merging the files, were they delimited. I am trying to figure out if that is the problem. I am enclosing an example of a file that I am using: "DI554K",2103,525,0,"..",5,1222,200637,0,999948,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999940,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999939,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,870185,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,999938,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,832338,1, 0,2 "DI554K",2103,525,0,"..",5,1222,200637,0,1060,1,0, 2 -- Larry E. Brueshaber "Tom Ogilvy" wrote: Code is tested and runs without a hitch for me. xl2003 even if SrcName were empty, that line won't raise an error: Demo'd from the immediate window: ? dir("") < "" True Now if SrcName = "some non existent path" You will get a 52 error or similar. Nothing I can do about it if you have bad data in your listbox. -- Regards, Tom Oglvy "Larry" wrote in message ... Running the module it is debugging to the line "If Dir(SrcName) < "" Then" then it exits. and the only thing created is an empty file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = Userform1.ListBox1 '<=== sample correction For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... I understand the problem now. The problem is I am on a Userform instead of an active worksheet. Sorry about the mis-understanding. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Here is an example from the immediate window demonstrating it working perfectly set lbox = Activesheet.Listbox1 ? lbox.name ListBox1 ? typename(lbox) ListBox There was an issue with two variables being reversed - but you haven't reached that line yet, so no bearing on the above. Anyway here is a tested revision. It of course assume you a have a listbox from the control toolbox toolbar on the activesheet when you run the macro and the listbox has a list of fully qualified text file names. Sub AppendFiles1() Dim SourceNum As Long Dim DestNum As Long Dim Temp As String Dim SrcName As String Dim lbox As MSForms.ListBox Dim i As Long ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "E:\AA_Text\AAA_DEST.TXT" For Append As DestNum Set lbox = ActiveSheet.ListBox1 For i = 0 To lbox.ListCount - 1 SrcName = lbox.List(i) If Dir(SrcName) < "" Then ' Open the source text file. SourceNum = FreeFile() Open SrcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #SourceNum End If ' Dir(srcName) < "" Next i Close #DestNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & SrcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... Entering in the Code, when running the module the following error "Object doesn't support this property or method" appears in line "set lbox = activesheet.listbox1". Thank you for your continues support. -- Larry E. Brueshaber "Tom Ogilvy" wrote: Assumes the Listbox is from the control toolbox toolbar and is on the activesheet. Sub AppendFiles1() Dim SourceNum As Integer Dim DestNum As Integer Dim Temp As String Dim SrcName as String Dim lbox as MSForms.Listbox ' If an error occurs, close the files and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "C:\DEST.TXT" For Append As DestNum set lbox = ActiveSheet.Listbox1 for i = 0 to lbox.Listcount - 1 SrcName = lbox.List(i) if Dir(srcName) < "" then ' Open the source text file. SourceNum = FreeFile() Open srcName For Input As SourceNum ' Read each line of the source file and append it to the ' destination file. Do While Not EOF(SourceNum) Line Input #SourceNum, Temp Print #DestNum, Temp Loop CloseFile: ' Close the source file. Close #DestNum End if ' Dir(srcName) < "" Next i Close #SourceNum Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) & " " & srcName Resume CloseFile End Sub -- Regards, Tom Ogilvy "Larry" wrote in message ... the listbox has a list of fully qualified filenames for text files which I want to combine into one large file. -- Larry E. Brueshaber "Tom Ogilvy" wrote: You mean the listbox has a list of fully qualified filenames for |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
merging zip files! | Excel Discussion (Misc queries) | |||
merging two files | Excel Discussion (Misc queries) | |||
Merging files | Excel Programming | |||
Merging two different files | Excel Discussion (Misc queries) | |||
Merging Files | Excel Programming |