Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just want to say how much I value your site. I hope the good work keeps up there. It's really helped me..."

Geography

Where in the world do Tek-Tips members come from?
mickyfinn (TechnicalUser)
2 May 01 14:48
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
Macbride (Programmer)
31 May 01 13:29
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



Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close