+ Reply to Thread
Results 1 to 5 of 5

Save As CSV (with "")

  1. #1
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Save As CSV (with "")

    Hi

    I'm trying to write some script which will save a worksheet as a csv file. I can get it to create the csv, but the system requires that any text formatted values be enclosed by "".

    So I wrote a little script which adds the "" around text values prior to saving as csv. To my bewilderment, the result was text surrounded by 3 sets of "".

    So TEXT should be "TEXT" but came out """TEXT"""!

    I've attached the original xls spreadsheet (Example Feeder.xls), the csv file produced by the main code below (Example Feeder.txt) and the csv prodcued by adding the code at bottom, which wraps all text values in "" prior to saving (Example Feeder (with quotes).txt).

    Does anybody have any ideas what I'm doing wrong?

    Dion


    Please Login or Register  to view this content.

    The code to add "" is as follows:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mojo249; 01-26-2010 at 10:57 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Save As CSV (with "")

    Hi mojo249
    do you want to save the file as a CSV or txt file?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Save As CSV (with "")

    Something worth reading:

    http://support.microsoft.com/kb/291296

    The QuoteCommaExport macro here should help.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Save As CSV (with "")

    also this Aaron Blood and Walkenbach example
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Save As CSV (with "")

    Thanks to both.

    That's the first time MS has managed to solve my problem.....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1