I’m using this chunk of code to convert a dataprovider to a csv file
Sub ExportCSV()
Dim bodoc As busobj.Document
Dim boDP As busobj.DataProvider
Dim strOutputFileName As String
Set bodoc = ActiveDocument
Set boDP = bodoc.DataProviders.Item(1)
strOutputFileName = "C:\CSVOutput.csv"
Call boDP.ConvertTo(boExpAsciiCSV, 1, strOutputFileName)
End Sub
When this converts the dp to the csv file, any commas in the fields remain there, thus creating more fields.
Is there a solution to this such as encapsulating the fields before they’re outputted to the csv file?
My advice is much like the old joke:[list]Patient: Doctor, my neck hurts when I bend it like this!
Doctor: Well, then don’t bend it that way![/list]I always use tab-delimited files, instead of CSV. Many import / export routines will honor quotes as encapsulation markers, but what if your data naturally contains quotes? You’re back to the same situation. I find Tab characters to be much more reliable, and almost any import routine that can handle CSV can also handle tab-delimited.
I tried using this code. It does not appear to be a true comma delimited format. The empty cells come out with ‘,#EMPTY,’ in the file. In a true comma delimited file it comes out as ‘,’. I cannot use a file with ‘,#EMPTY,’.