View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Mike D.[_2_] Mike D.[_2_] is offline
external usenet poster
 
Posts: 7
Default Saving a woorkbook as a TXT file keeping its current name

'Make a variable named Fname

Fname = ActiveWorkbook.Name

Use the InStr keyword to trim out the ".xls" (I can't
remember the whole syntax, but something like: InStr
(Fname, ".xls", <can't remember the rest, but when you
start typing the syntax should pop up)

'after that add the ".txt"
Fname = Fname & ".txt"

'next save it
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\" & Fname, FileFormat:= _
xlText, CreateBackup:=False




-----Original 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/

.