Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi-
I need excel to export ASCII text data with quotes around each field, not just fields that contain a comma. Our data needs to be shipped to a program that always expects the quotes. Excel only puts a quote around a field with a comma in it. I want excel to do it always? Thanks, |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You need a macro
Sub WriteCSV() Const myFileName = "c:\temp\myfile.csv" Const ForReading = 1, ForWriting = 2, _ ForAppending = 3 Set fs = CreateObject("Scripting.FileSystemObject") FileSaveName = Application.GetSaveAsFilename( _ fileFilter:="Text Files (*.CSV), *.CSV") If FileSaveName = False Then MsgBox ("Cannot Get Filename - Exiting Macro") Exit Sub End If Set f = fs.CreateTextFile _ (Filename:=FileSaveName, overwrite:=True) Lastrow = Range("A" & Rows.Count).End(xlUp).Row For RowCount = 1 To Lastrow LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Columns If LastCol = 1 And _ Range("A" & RowCount) = "" Then 'if row is empty write blank line f.writeline Else OutputLine = "" For ColCount = 1 To LastCol If ColCount = 1 Then OutputLine = Chr(34) & Cells(RowCount, ColCount) & Chr(34) Else OutputLine = OutputLine & "," & _ Chr(34) & Cells(RowCount, ColCount) & Chr(34) End If Next ColCount f.writeline OutputLine End If Next RowCount f.Close End Sub "Rich DeVito" wrote: Hi- I need excel to export ASCII text data with quotes around each field, not just fields that contain a comma. Our data needs to be shipped to a program that always expects the quotes. Excel only puts a quote around a field with a comma in it. I want excel to do it always? Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
export re-order input fields to export file [csv] | Excel Worksheet Functions | |||
change straight quotes to curly quotes | Excel Discussion (Misc queries) | |||
How do i get historical stock quotes using MSN Money Stock Quotes | Excel Discussion (Misc queries) | |||
excel quotes | Excel Worksheet Functions | |||
export .CSV with field containing double quotes? | Excel Discussion (Misc queries) |