Macro to count lines and save in differents files
Mr. Doug,
Thank you to help me.
The problem is to cut a text around 2000 or 3000 LINES (not paragraph)
indepent if line is blanck or not and save in a different files.
Example:
Open a text name GURU.doc
This text GURU.doc have 60 lines.
Cut this text and save this in number of files that contain 20 line each.
GURU01.doc start at line 00 and finish at line 20
GURU02.doc start at line 21 and finish at line 40
GURU03.doc start at line 40 and finish at line 59
Thank's in advanced
"Doug Robbins - Word MVP" wrote:
If these are just lines rather than paragraphs, there is a problem because
lines do not mean very much in Word.
If each line is actually a separate paragraph, then something like the
following would do it:
Dim i As Long
Dim Source As Document, target As Document
Dim arnge As Range
i = 0
For i = 0 To 150
Set Source = ActiveDocument
Set arnge = Source.Range
arnge.Start = Source.Range.Start
arnge.End = Source.Paragraphs(20).Range.End
Set target = Documents.Add
target.Range.FormattedText = arnge.FormattedText
target.SaveAs "C:\Test\File" & Format(i, "000")
target.Close
arnge.Delete
Next i
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Jr" wrote in message
...
Hi all,
How to make a Macro to count 20 lines in a text with 3000 lines and save
every 20 lines in new file with total 150 new arquives starting in
File000.doc, file001.doc.., File150.doc?
I´ve tried to put a text with 2000 lines in word 2003 and start macro
count line 1 to line 20, file save as give a name file000.doc, start again
in line 21 go to line 40 filesave as give a name file001.doc. But nothing
work, this macro don't save the file.
Thank´s in advanced
jr
|