Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Merging 2 list documents.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MikeAdams - 02 Aug 2006 16:12 GMT
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.
Helmut Weber - 02 Aug 2006 17:04 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.