Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
merging zip files! via135 Excel Discussion (Misc queries) 2 November 19th 06 05:32 PM
merging two files mcap Excel Discussion (Misc queries) 3 April 9th 06 07:28 PM
Merging files mac_see[_3_] Excel Programming 2 March 5th 05 02:09 AM
Merging two different files justinfisher Excel Discussion (Misc queries) 0 January 21st 05 08:53 PM
Merging Files rglasunow[_13_] Excel Programming 3 February 3rd 04 01:27 AM


All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"