veematics
asked on
Excel: Add double quotes on exported CSV from field
I tried to export CSV with this command:
ActiveWorkbook.SaveAs Filename:=fileresult, FileFormat:=xlCSV, CreateBackup:=False
But the exported CSV doesn't have double quote for each cell except the "Wrap Text" ones (item.csv as attached)
.
Then i tried to add this command:
Set SrcRg = ActiveSheet.UsedRange
For Each CurrRow In SrcRg.Rows
For Each CurrCell In CurrRow.Cells
CurrCell.Value = Chr(34) & CurrCell.Value & Chr(34)
Next
Next
it visually display the double quotes, but when i open the raw source of CSV, it consist 3 double quotes, for example:
"""product_sku""","""produ ct_price"" ","""categ ory_path"" ","""produ ct_type""" ,"""parame ter""",""" product_le ngth"""
(Item2.csv as attached)
So... how to solve this problem ?
Item.csv
Item2.csv
ActiveWorkbook.SaveAs Filename:=fileresult, FileFormat:=xlCSV, CreateBackup:=False
But the exported CSV doesn't have double quote for each cell except the "Wrap Text" ones (item.csv as attached)
.
Then i tried to add this command:
Set SrcRg = ActiveSheet.UsedRange
For Each CurrRow In SrcRg.Rows
For Each CurrCell In CurrRow.Cells
CurrCell.Value = Chr(34) & CurrCell.Value & Chr(34)
Next
Next
it visually display the double quotes, but when i open the raw source of CSV, it consist 3 double quotes, for example:
"""product_sku""","""produ
(Item2.csv as attached)
So... how to solve this problem ?
Item.csv
Item2.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The quotes are being added to the "wrap text" fields because they contain one or more comma characters.
Since the Chr(34) character is, itself, used as a delimiter in CSV files, they must be handled differently. The three consecutive quote character sequences you see are the Chr(34) character that is being delimited by quote characters.
I'm not sure I fully understand what you need. Have you considered tab-separated (delimited) values, rather than comma-separated?
Since the Chr(34) character is, itself, used as a delimiter in CSV files, they must be handled differently. The three consecutive quote character sequences you see are the Chr(34) character that is being delimited by quote characters.
I'm not sure I fully understand what you need. Have you considered tab-separated (delimited) values, rather than comma-separated?
I've requested that this question be deleted for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER
Hello i was out of town for almost a month...
http://www.mrexcel.com/forum/showthread.php?t=320531