-2

I have a recordset of a database and should write it row by row into a csv file.

Now it is possible, that there are quotes in a field which leads to an invalid formed csv.

field = This leads"; to problems

In the csv file [ ; ] is the delimeter and ["..."] the field capture.

How to correctly escape the quotes ?

  • 1
    Possible duplicate of [Properly escape a double quote in CSV](https://stackoverflow.com/questions/17808511/properly-escape-a-double-quote-in-csv) – Tin Aug 31 '18 at 15:01
  • Possible duplicate of Properly escape a double quote in CSV. Correct solution: https://stackoverflow.com/a/17808731/4954434 – Jithin Pavithran Dec 28 '20 at 09:49

1 Answers1

0

In my case I had to replace all <"> in the string with <"">

vba:
Replace(field,Chr(34),Chr(34) & Chr(34))

ore more generic

pseudo
quote = "\""
replace(field,quote,quote + quote)

reference was @tommed to the answer of user4035