I am trying to convert ~200 xlsx files in a directory to txt using vb. Is the below attempt close or what is the best way? Thank you
.
VB
Sub convert()
ChDir "C:\Users\cmccabe\Desktop\epilepsy"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\cmccabe\Desktop\epilepsy\*.txt", _
FileFormat:=xlText, CreateBackup:=False
End Sub
or maybe:
Sub Convert()
Dim strPath As String
Dim strFile As String
Dim wbk As Workbook
' DEFINE LOCATION '
strPath = "C:\Users\cmccabe\Desktop\epilepsy\xlsx\"
strFile = Dir(strPath & "*.*")
Do While strFile <> ""
Set wbk = Workbooks.Open(FileName:=strPath & strFile)
wbk.SaveAs FileName:=strPath & strFile, _
FileFormat:=xlText
wbk.Close SaveChanges:=True
strFile = Dir
Loop
End Sub
Bookmarks