ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save a workbook using FileFormat in .txt but with data in csv for (https://www.excelbanter.com/excel-programming/354612-save-workbook-using-fileformat-txt-but-data-csv.html)

yves

Save a workbook using FileFormat in .txt but with data in csv for
 
Hi all,
I have a workbook with data in rows and columns and I want to save it as a
csv text file but with a .txt extension and not a .csv extension. This .txt
file is then read by another programm.
If I save it with the Excel available .txt extensions, the txt file produced
is always a tab file.
The only code that produces the format I am looking for is:
ActiveWorkbook.SaveAs filename:=Range("A3").Value, FileFormat:=xlCSV,
CreateBackup:=False
ChDir "C:\Documents and Settings\Administrador\Escritorio"
but the file produced is with a .csv extension and what I want is a .txt
I really need to produce it direct and not have to use the Office rename
function.
Any ideas? Thks.


Chris Marlow

Save a workbook using FileFormat in .txt but with data in csv for
 
Yves,

If your Range("A3") ends in ".txt" or you change the line saving to;

ActiveWorkbook.SaveAs filename:=Range("A3").Value & ".txt",
FileFormat:=xlCSV, CreateBackup:=False

That wil force the filename to finish .txt not .csv

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Yves" wrote:

Hi all,
I have a workbook with data in rows and columns and I want to save it as a
csv text file but with a .txt extension and not a .csv extension. This .txt
file is then read by another programm.
If I save it with the Excel available .txt extensions, the txt file produced
is always a tab file.
The only code that produces the format I am looking for is:
ActiveWorkbook.SaveAs filename:=Range("A3").Value, FileFormat:=xlCSV,
CreateBackup:=False
ChDir "C:\Documents and Settings\Administrador\Escritorio"
but the file produced is with a .csv extension and what I want is a .txt
I really need to produce it direct and not have to use the Office rename
function.
Any ideas? Thks.



All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com