i need to copy first 10 rows from file1 and pasting in file2. i am writing the code as

<code>
Dim FNum1 As Integer
Dim FNum2 As Integer

Dim str As String

Open "C:\file1.txt" For Input As #FNum1
Open "C:\file2.txt" For output As #FNum2

Line Input #FNum1, str
Print #FNum2, str

Close #FNum1
Close #FNum2
</CODE>

but while opening the second file it gives an error as bad file name or number.

please help me out and let me know how to handle two files simultaneously.

Hi
I think you need to assign different number to each file number. You are opening each file using the same number, thus will have error. Try to use FreeFile. It will supply a number that is not being used or simply you assign different number like 1 and 2 respectively.

example
<code>

FNum1 = FreeFile
Open "C:\file1.txt" For Input As #FNum1

FNum2 = FreeFile
Open "C:\file1.txt" For Input As #FNum2

</code>

Hope this help.