SaveAs tab delimited text file

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

Guest

Hi,

I'm trying to simply save an excel worksheet as a tab delimited text file. I'm calling

ws.SaveAs "c:\test.txt", FileFormat=xlTextWindows

It saves the file just file, but when I open the text file, I get a lot of random characters and it doesn't display as it does as if I were to do it through Excel's IDE. Am I calling something wrong to not get the correct tab delimited text file or am I forgetting something? Thanks.

Mark
 
Try this

FileFormat:=xlText

Something like this

Sub Save_ActiveSheet_TXT_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String

strdate = Format(Now, "dd-mm-yy h-mm-ss")
Fname = "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".txt"

Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlText
.Close False
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


Mark said:
Hi,

I'm trying to simply save an excel worksheet as a tab delimited text file. I'm calling

ws.SaveAs "c:\test.txt", FileFormat=xlTextWindows

It saves the file just file, but when I open the text file, I get a lot of random characters and it doesn't display as it does as
if I were to do it through Excel's IDE. Am I calling something wrong to not get the correct tab delimited text file or am I
forgetting something? Thanks.
 
Back
Top