Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word transferring large doc into several small docs

Status
Not open for further replies.

kawnz

Technical User
Jan 30, 2003
67
0
0
US
I have a text file that I am unable to import into excel. The file is over 2000 pages long when I load it into word. Is there a way to save this text file into shorter text files - say 20 files of about 100 pages? How would I do this?
 
The easiest way is probably to import it into Access first and the run queries to make smaller groups for Excel.

There are also some utilities you could download that split files. Google "UnxUtils.zip" or try and use either the 'head.exe', 'tail.exe' or 'split.exe' from DOS.

ALternatively, you could use VBA, windows scripting, or some other programming language to write your own low level text splitting function.

Brian
 
Hi kawnz,

A 2000 'page' file would probably hold around 140,000 lines of data, assuming no manual page breaks.

An Excel worksheet can hold up to 65536 lines per worksheet.

You could use a macro to import the file, adding a new sheet every 65536 rows, but you might find it quicker to manually split the file into three parts and open each part as a .csv or .txt file.

Cheers
 
This would import a large tex file into excel
Sub LargeFileImport()

Dim ResultStr As String
Dim FileName As String
Dim FileNum As Integer
Dim Counter As Double
FileName = InputBox("Please enter the Text File's name, e.g. S:\Revenue\Straus\BATCHOCCMUM121002.txt")
If FileName = "" Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Application.ScreenUpdating = False
Workbooks.Add template:=xlWorksheet
Counter = 1
Do While Seek(FileNum) <= LOF(FileNum)
Application.StatusBar = "Importing Row " & _
Counter & " of text file " & FileName
Line Input #FileNum, ResultStr
If Left(ResultStr, 1) = "=" Then
ActiveCell.Value = "'" & ResultStr
Else
ActiveCell.Value = ResultStr
End If

If ActiveCell.row = 65536 Then
ActiveWorkbook.Sheets.Add
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
Application.StatusBar = False

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top