Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenate Text File


Are you saying there is not a command to contatenate two text files i
VBA

--
RickKenned
-----------------------------------------------------------------------
RickKennedy's Profile: http://www.excelforum.com/member.php...fo&userid=1541
View this thread: http://www.excelforum.com/showthread.php?threadid=27029

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Concatenate Text File

shell("copy master.txt + file1.txt file2.txt")

--
Regards,
Tom Ogilvy

"RickKennedy" wrote in message
...

Are you saying there is not a command to contatenate two text files in
VBA?


--
RickKennedy
------------------------------------------------------------------------
RickKennedy's Profile:

http://www.excelforum.com/member.php...o&userid=15419
View this thread: http://www.excelforum.com/showthread...hreadid=270290



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Concatenate Text File

No, there's no single command to do that. However, if the 2nd file is less
than the maximum allowed for a single string (2^31 bytes), you can do this:

File1 = "FirstFile.Txt"
File2 = "SecondFile.Txt"

Open File1 For Binary As #1
Seek #1, LOF(1) + 1
Open File2 For Binary AS #2
X = Space$(LOF(2))
Get #2, 1, X
Put #1, , X
Close #1, #2

If it's binary data and too big to read into a single string, you would have
to read in blocks, most probably adjusting the size of the the string variable
when reading the last block. IOW, you would have to keep track of the number
of bytes left, and if it's less than the length of X, redefine X to the number
of bytes left before the last Get statement.

If the 2nd file is too large, and it consists of lines ending with CR/LF, you
can do it the old fashioned way:

File1 = "FirstFile.Txt"
File2 = "SecondFile.Txt"
Open File1 For Append As #1
Open File2 For Input AS #2
Do While Not EOF(2)
Line Input #2, X
Print #1, X
Loop
Close #1, #2



On Tue, 19 Oct 2004 10:06:35 -0500, RickKennedy
wrote:


Are you saying there is not a command to contatenate two text files in
VBA?


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
TEXT & DATES & CONCATENATE Finance Guru Excel Discussion (Misc queries) 1 May 28th 09 04:59 PM
How to concatenate cell & text in a text box? Jimbo213 Excel Worksheet Functions 3 March 28th 08 09:00 PM
CONCATENATE text formula Lauren Excel Worksheet Functions 7 January 7th 06 10:24 PM
Using Concatenate function to generate text in Text Box Mary S. Charts and Charting in Excel 1 December 14th 05 08:55 PM
Concatenate Text File RickKennedy Excel Programming 1 October 18th 04 10:31 PM


All times are GMT +1. The time now is 06:47 AM.

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

About Us

"It's about Microsoft Excel"