Is it possible to bulk export multiple sheets in an Excel Document to separate tab-delimited text files? As it is, it only exports the active sheet. I've got a document with 850 sheets, all of which I'd like to get exported as tab-delimited.
Asked
Active
Viewed 718 times
1
-
Take a look [here](http://stackoverflow.com/questions/9805124/need-to-modify-this-export-macro-for-text-tab-delimited-output) or [here](http://stackoverflow.com/questions/59075/macro-to-save-each-sheet-in-an-excel-workbook-to-separate-csv-files) – Raystafarian Mar 29 '12 at 19:54
-
I should note I'm on OS X Excel 2008. THat one solution uses stuff with shell32.dll. We already gave that one a shot, but failed there. – Keefer Mar 29 '12 at 20:03
1 Answers
1
Quick and simple would be something like this:
Public Sub ExportSheets(wbk As Workbook, sPath As String)
Dim sht As Worksheet
For Each sht In wbk.Worksheets
sht.Select
sht.SaveAs sPath & sht.Name & ".txt", XlFileFormat.xlTextMac
Next sht
wbk.Close
MsgBox "Done exporting."
End Sub
On Windows, you would call this by typing ExportSheets ActiveWorkbook, "C:\Data\" in the immediate window.
Note I'm closing the workbook when done because the workbook is now the last saved text file and not the original workbook.
mischab1
- 1,312
- 8
- 10