Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change delimiter character for SDK .csv export

Status
Not open for further replies.

mickyfinn

Technical User
Dec 27, 2000
2
0
0
US
SDK has methods for exporting to .csv. We would like to change the delimiter character to a comma, which is not one of the options. Has anyone written code to support this?

Thanks for your help.

Micky
 
Hello mickyfinn,

Please find some code I wrote a long time agoo to do that kind of thing. I'm sure you will modify it to fit your needs but I think it could be a good start!
I hope it will help.
Cheers,

Sub Main()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim L As Integer
Dim Doc As Document
Dim DP As DataProvider
Dim str As String
Dim File
Dim Sep2 As String
Set Doc = ActiveDocument

For i = 1 To Doc.DataProviders.Count
Sep = InputBox("Please specify your separator for the dataprovider " & Doc.DataProviders.Item(i).Name)
File = InputBox("Please specify a file location for the dataprovider " & Doc.DataProviders.Item(i).Name)
Open File For Output As #1
Set DP = Doc.DataProviders.Item(i)
str = ""
For j = 1 To DP.Columns.Count
'DP.Columns.Item(i).Name
If j = DP.Columns.Count Then Sep2 = "" Else Sep2 = Sep
str = str & DP.Columns.Item(j).Name & Sep2
Next j
'Write the columns name in the text file
Print #1, str
str = ""
For k = 1 To DP.Columns.Item(i).Count
str = ""
For L = 1 To DP.Columns.Count
If DP.Columns.Item(L).Item(k) = "#EMPTY" Then Chain = " " Else Chain = DP.Columns.Item(L).Item(k)
If L = DP.Columns.Count Then Sep2 = "" Else Sep2 = Sep
str = str & Chain & Sep2
Next L
'Write the column contents
Print #1, str
Next k
Close #1
Next i
End Sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top