Convert multiple XLS files to TXT

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to convert hundreds of XLS files to TXT. I am aware of File/Save-as
and I also tried written a macro. Neither solution is workable even the
number of files I have to convert. Does Excel have a mass convert utility?
 
One possibility is to loop through all the files and convert the extension
from .xls to .txt. Try:

Sub ChangeXLStoTXT()
'Based on some old code from me
'with modifications from Dave Peterson
Dim MyFolder As String
Dim NewName As String
Dim i As Long
MyFolder = "C:\Program Files\ztest" '<----Change
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = MyFolder
.SearchSubFolders = False
.Filename = "*.xls"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
NewName = Left(.FoundFiles(i), _
Len(.FoundFiles(i)) - 4) & ".txt"
Set Wkbk = Workbooks.Open(Filename:=.FoundFiles(i))
With Wkbk
Application.DisplayAlerts = False
.SaveAs Filename:=NewName
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next
Else
MsgBox "There were no files found."
Exit Sub
End If
End With
Application.ScreenUpdating = True
End Sub
 
The last file conversion utility Excel included was in Excel 97, as far as I
know:

http://support.microsoft.com/default.aspx?scid=kb;en-us;161325

I don't know what formats it offered. If you cannot get this you might
revisit your macro as a macro can do this sort of thing quite easily.

--
Jim
|I need to convert hundreds of XLS files to TXT. I am aware of File/Save-as
| and I also tried written a macro. Neither solution is workable even the
| number of files I have to convert. Does Excel have a mass convert
utility?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top