This topic has not yet been rated - Rate this topic

How to: Open Text Files as Workbooks

You can open a text file as a workbook. You must pass in the name of the text file you want to open. You can specify several optional parameters, such as which row number to start parsing on and the column format of the data in the file.

Applies to: The information in this topic applies to document-level projects and application-level projects for Excel 2007 and Excel 2010. For more information, see Features Available by Office Application and Project Type.


this.Application.Workbooks.OpenText(@"C:\Test.txt",
    missing, 3,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    missing, missing, missing, true, missing, missing, missing, 
    missing, missing, missing, missing, missing, missing);


This example requires the following components:

  • A comma-delimited text file named Test.txt that contains at least three lines of text.

  • The text file Test.txt to be stored on drive C.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ