Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Saving a file xls as a txt format

  Asked By: Lloyd    Date: Sep 08    Category: MS Office    Views: 1457
  

I wrote this code:

Sub CommandButton1_Click()
ruta = ActiveWorkbook.Path
Sheets("Hoja de datos").Select
Sheets("Hoja de datos").Copy
nombre = ActiveWorkbook.Name
CompletePathName = ruta & "\" & nombre
ActiveWorkbook.SaveAs Filename:=CompletePathName,
FileFormat:=xltxt
mensaje = "La hoja de datos se guardo en " & ruta
MsgBox (mensaje)

End Sub

The problem is that the file is stored in format xls, instead of txt.
What did I do wrong?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Blake Smith     Answered On: Sep 08

The ActiveWorkbook.name = *.xls (I believe this would supercede the
conflicting request to save as *.txt)

You want nombre to equal everything to the left of the '.xls'

So, nombre = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)

 
Answer #2    Answered By: Ryder Anderson     Answered On: Sep 08

Are you sure it's saving  as Excel format, or is it simply that the file  has
extension XLS?

Actually, it looks as though you're trying to save the workbook over itself.
You need to specify a different path or a different file name in your save.

If you want it to have extension TXT, you need to remove the XLS from the
file name and replace it with TXT.

 
Didn't find what you were looking for? Find more on Saving a file xls as a txt format Or get search suggestion and latest updates.




Tagged: