How to export Excel data to Text files in Excel?
If you are required to deliver a workbook in the format of text file, you need to convert the workbook into text files. And this article will introduce you two methods to export Excel data into text files easily.
Classic Menu for Office: brings back classic menus to Office 2010 and 2013 (includes Office 365).
Office Tab: brings tabbed interface to Office as the use of web browser Chrome, Firefox and Internet Explorer.
By default, the Excel data will be saved as workbooks in the format of .xlsx. However, we can export a worksheet of existing workbook as text files with the following steps:
Step 1: Click the Save as button under File tab in Excel 2010; in Excel 2007 click the Office Button and Save as button;
Step 2: Save As dialog box comes out. Name the file in the File name text box and select the folder that you will save the file in;
Step 3: In the Save as type drop down list, select the Unicode Text . See screenshot:
Step 4: Then it will pop up two warning dialog boxes asking you to export only active worksheet as text file and leave out any incompatible features with text file. Click OK and Yes.
Then the data in the active worksheet are exported as a new text file.
Note: the Save As command is only able to export data of active worksheet as a text file. If you want to export all data of the whole workbook, you need to save each worksheet as a text file individually.
The following VBA code also can help you to export the selected range data or entire worksheet to the text file, please do as this:
Step 1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 2. Click Insert > Module, and paste the following code in the Module Window.
VBA: export selection or entire worksheet to text file
Sub ExportRangetoFile() 'Update 20130913 Dim wb As Workbook Dim saveFile As String Dim WorkRng As Range On Error Resume Next xTitleId = "KutoolsforExcel" Set WorkRng = Application.Selection Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8) Application.ScreenUpdating = False Application.DisplayAlerts = False Set wb = Application.Workbooks.Add WorkRng.Copy wb.Worksheets(1).Paste saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt") wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False wb.Close Application.CutCopyMode = False Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
Step 3. Then press F5 key to run this code, and a prompt box will pop out to tell you to select the data range that you want to export, see screenshot:
Note: If you want to export the entire worksheet, in the above prompt box, hold down the Ctrl + A keys.
Step 4. Then click OK, and specify a name for this text file and a folder to put this file in the popped out Save As dialog.
Step 4. Then click Save button, and the selected data range has been exported as text file.
The Save As command can export all data in the active worksheet as text. What if exporting all data of specified inactive worksheets, or part of the data in a worksheet as a text file? Kutools for Excel's Export Range to File tool can help us export and save the data in any worksheet as text file easily no matter it is active or not.
Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.
After installing Kutools for Excel, please do as following steps:
Step 1: Click Enterprise > Import / Export > Export Range to File, see screenshot:
Step 2: In the Export Range to File dialog box, do following options:
- (1.) Click the button to select a range that you want to export its data as a text file. If you want to export the entire worksheet, after clicking the button, then hold down the Ctrl + A keys.
- (2.) Then check the Unicode Text option under File format, and then choose the text options as you need, see screenshot:
Step 3: Then click OK, and specify a name and a location for the exported range file.
Step 4: And then click Save, now the selected range is exported as a new text file. See screenshot:
Kutools for Excel's Export Range to File tool makes it possible to easily export a range of date to a file, either an Excel workbook, a CSV, a simple HTML or all formatting HTML.
- Export Excel data to CSV files in Excel
- Export Excel data as HTML
- Save a selection as individual file
- Save selection or entire workbook as PDF