2

Is it possible to save a copy of a workbook as txt file?

I tried ThisWorkbook.SaveCopyAs("wb.txt"). However this saves the excel with txt without any file conversion. So when I open the text file no data is displayed.

Community
  • 1
  • 1
timbmg
  • 3,192
  • 7
  • 34
  • 52

2 Answers2

3

Another way

ThisFile = "Filename"
code.....
ActiveWorkbook.SaveAs Filename:="\folderlocation\" & ThisFile & ".txt", FileFormat:=xlText
mrbungle
  • 1,921
  • 1
  • 16
  • 27
2
Application.DisplayAlerts = False
Dim s As String
s = ActiveWorkbook.FullName
s = Replace(s, "xlsx", "txt")
ActiveWorkbook.SaveAs Filename:=s, FileFormat:=xlCurrentPlatformText
ActiveWorkbook.Close
Application.DisplayAlerts = True

This will silently save file in txt format and close original file.

Also you can find some info here.

Community
  • 1
  • 1
gofr1
  • 15,741
  • 11
  • 42
  • 52