"File not loaded completely" error importing text files larger than 65536 rows in Mac XL (190032)



The information in this article applies to:

  • Microsoft Excel 2004 for Mac
  • Microsoft Excel X for Mac
  • Microsoft Excel 2001 for Mac
  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q190032

SYMPTOMS

If you open a text file in Microsoft Excel that contains more than 65536 rows, you may receive the following error message
File not loaded completely
and the text file is truncated at row 65536.

CAUSE

Worksheets in Excel have a limit of 65536 rows.

WORKAROUND

You can use a Visual Basic for Applications macro to open the file and automatically break the text into multiple worksheets. The "More Information" section of this article contains a sample macro to open a text file with more than 65536 rows.

STATUS

This is by design of Microsoft Excel.

MORE INFORMATION

The following sample macro prompts you for a text file name, and then opens the file in memory. If the number of rows is larger than the Microsoft Excel worksheet limit of 65536, the macro breaks the file into multiple worksheets. This macro applies only to files you saved as text files and does not apply to any other file formats. The macro will not work with database file formats.

Note that because this is a macro, using it may be significantly slower than clicking Open on the File menu.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
   ' All lines that begin with an apostrophe (') are remarks and are not
   ' required for the macro to run.

   Sub LargeFileImport()

      ' Dimension Variables.
      Dim ResultStr As String
      Dim FileName As Variant
      Dim FileNum As Integer
      Dim Counter As Double

      ' Ask User for file's name.
      FileName = Application.GetOpenFilename("TEXT")

      ' Check for no entry.
      If FileName = False Then End

      ' Get next available file handle number.
      FileNum = FreeFile()

      ' Open text file for input.
      Open FileName For Input As #FileNum

      ' Turn screen updating off.
      Application.ScreenUpdating = False

      ' Create a new workbook with one worksheet in it.
      Workbooks.Add template:=xlWorksheet

      Counter = 1
      ' Loop until the end of file is reached.
      Do While Seek(FileNum) <= LOF(FileNum)
         ' Display importing row number on status bar.
          Application.StatusBar = "Importing Row " & _
             Counter & " of text file " & FileName
          ' Store one line of text from file to variable.
          Line Input #FileNum, ResultStr
          ' Store variable data into active cell.
          If Left(ResultStr, 1) = "=" Then
             ActiveCell.Value = "'" & ResultStr
          Else
             ActiveCell.Value = ResultStr
          End If
          If ActiveCell.Row = 65536 Then
             ' If on the last row then add a new sheet.
             ActiveWorkbook.Sheets.Add
          Else
             ' If not the last row then go one cell down.
             ActiveCell.Offset(1, 0).Select
          End If
          ' Increment the counter by 1.
          Counter = Counter + 1
      ' Start again at top of 'do while' statement.
      Loop
      ' Close the open text file.
      Close
      ' Remove message from status bar.
      Application.StatusBar = False

   End Sub
				
NOTE: The macro does not parse the data into columns. After using the macro, you may also need to use the Text To Columns command on the Data menu to parse the data as needed.

REFERENCES

For more information about the Text Import Wizard, click Excel Help or Search Excel Help on the Help menu, and then type the following text:

Text Import Wizard

Click Search to view the topics that are available.

In Excel 2001, for more information about the Text Import Wizard, click Contents and Index on the Help menu, click Search, and then type the following text:

importing text files

Click Search again. Select the "Open an entire text file in Microsoft Excel" topic.

In Excel 98, for more information about the Text Import wizard, click Contents and Index on the Help menu (or on the Balloon Help menu if you are using a version of the Macintosh operating system earlier than version 8.0). Click the Index button in Microsoft Excel 98 Help, and then type the following text:

importing data, text files

Click Show Topics.

Select the "View or save files from other programs as Microsoft Excel workbooks" topic, and click Go to. If you are unable to find the information that you need, ask the Office Assistant for help.

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kbprb KB190032