Merging 2 list documents.

M

MikeAdams

I have 2 notepad documents consisting of 16 character lines. One is
380,000 lines, the other is 20,000 lines. Is there a way to merge the
two so that the 1st line of the smaller ends up as the 20th line of the
larger, second line of the smaller ends up as the 40th line of the
larger and so on untill all 20,000 lines are evenly distributed within
the larger giving me a final document of 400,000 lines consisting of
the lines of both original documents and an even distribution of the
20,000 lines within the 380,000. I couldn't use Excel because the
characters are digits and Excel truncates the last digit to a zero. I
have opened both within MS Word but couldn't find a setting for doing
this. Anyones help is greatfully appreciated.
 
H

Helmut Weber

Hi Mike,

not a Word question, but a question of general programming.

Like this, hoping your counting of lines is perfect!

Sub M389()
Dim s As String
Dim x As Long
' a file containing 380 lines
Open "c:\test\word\380.txt" For Input As #1
' a file containing 19 lines
Open "c:\test\word\19.txt" For Input As #2
' a file that will contain, hopefully, 399 lines
Open "c:\test\word\399.txt" For Output As #3
While Not EOF(1)
For x = 1 To 19 ' read 19 lines from file #1
Line Input #1, s
Print #3, s ' write 19 lines to file #3
Next
Line Input #2, s ' read 1 line from file #2
Print #3, s ' write 1 line to file #3
Wend
Close #1
Close #2
Close #3
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top