Link to home
Start Free TrialLog in
Avatar of veematics
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""","""product_price""","""category_path""","""product_type""","""parameter""","""product_length"""

(Item2.csv as attached)

So... how to solve this problem ?



Item.csv
Item2.csv
ASKER CERTIFIED SOLUTION
Avatar of Shanmuga Sundaram D
Shanmuga Sundaram D
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please see the following website if it can give you a hint.

http://www.mrexcel.com/forum/showthread.php?t=320531
please see the excel with macro and results attached
sample.xlsm
results.csv
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?
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.
Avatar of veematics
veematics

ASKER

Hello i was out of town for almost a month...