ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save As Text file (https://www.excelbanter.com/excel-programming/340133-save-text-file.html)

[email protected]

Save As Text file
 
Hi NG,
Would appreciate any assistance with this one.
I have searched the NG and not coming up with the right result I need.
I have the following code:

Sub SaveAsTxt()

Sheets("Output").Select
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:="C:\Sales\" & "Sales" & Format(Now,
"yyyymmddhhmm") & ".txt", FileFormat:=xlText, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False

Sheets("IMPUT").Select
Range("A2").Select

End Sub

the resulting output is as a TAB delimited text file.
I require COMMA ( , ) delimited, and contents with Double Quotes (""),
including blank fields.

Thanks in advance.
Cheers Paul


Tim Williams

Save As Text file
 
Need to use "csv" file format instead of just txt (FileFormat:=xlCSV)

Tim.

wrote in message
ups.com...
Hi NG,
Would appreciate any assistance with this one.
I have searched the NG and not coming up with the right result I
need.
I have the following code:

Sub SaveAsTxt()

Sheets("Output").Select
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:="C:\Sales\" & "Sales" & Format(Now,
"yyyymmddhhmm") & ".txt", FileFormat:=xlText, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False

Sheets("IMPUT").Select
Range("A2").Select

End Sub

the resulting output is as a TAB delimited text file.
I require COMMA ( , ) delimited, and contents with Double Quotes
(""),
including blank fields.

Thanks in advance.
Cheers Paul




[email protected]

Save As Text file
 
Thanks Tim, that's a help.
Cheers Paul

Tim Williams wrote:
Need to use "csv" file format instead of just txt (FileFormat:=xlCSV)

Tim.




All times are GMT +1. The time now is 12:10 AM.

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