View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Saving a woorkbook as a TXT file keeping its current name

Try this to save the activesheet as a txt file

Sub test()
Dim wb As Workbook
Set wb = ActiveWorkbook
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\" & Left(wb.Name, Len(wb.Name) - 4) & ".txt", FileFormat:= _
xlText, CreateBackup:=False
ActiveWorkbook.Close False
End Sub

More info you can find here
http://www.cpearson.com/excel/imptext.htm



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


"Chichifo " wrote in message ...
I'm really new to macros and I want to use a macro for several excel
files. I need to save them at the end as a Text (Tab delimited)(*.txt)
however I want to keep the original file name. How can I make Book1.txt
a variable so it will take the woorkbook name that the macro is
processing.

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Book1.txt", FileFormat:= _
xlText, CreateBackup:=False
THX.


---
Message posted from http://www.ExcelForum.com/