I have a workbook with about 20 sheets in it that need to be exported as tab delimited text files. I was able to find a couple variations of a VBA code to do this, but they both yield errors when I try to run them.
The first code I tried was:
Sub SaveAllAsTsv()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim filename As String
SaveToDirectory = CreateObject("WScript.Shell").specialfolders("Desktop")
For Each WS In ActiveWorkbook.Worksheets
filename = SaveToDirectory & "\" & WS.Name & ".txt"
WS.SaveAs filename, xlText, Local:=True
Next
End Sub
On that I get the error:
Run-time error '429':
ActiveX component can't create object
Does anyone know why this code isn't running properly on my computer? Perhaps it is because I am running a Mac?
I am attaching a test file with a few sheets of dummy data and the VBA code for convenience.
Bookmarks