+ Reply to Thread
Results 1 to 9 of 9

Saving As Txt file adds double quotes

  1. #1
    Registered User
    Join Date
    05-17-2019
    Location
    Ro
    MS-Off Ver
    2016
    Posts
    22

    Saving As Txt file adds double quotes

    Hello,

    I use the script below to process some data from a excel file. The output result must be saved in a TXT file. I facing issue when the .txt file is saved, all rows are wrapped with double quotes (initial data do not have quotation marks). How to prevent double quotes when saving? I tried so far to save as xlTextPrinter, partial works, no more quotes, but the file has mixed/unarranged rows.

    Please Login or Register  to view this content.
    Last edited by zGod; 10-16-2021 at 12:27 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Saving As Txt file adds double quotes


    Hello,

    try the VBA constant xlText as FileFormat …

  3. #3
    Registered User
    Join Date
    05-17-2019
    Location
    Ro
    MS-Off Ver
    2016
    Posts
    22

    Re: Saving As Txt file adds double quotes

    Quote Originally Posted by Marc L View Post

    Hello,

    try the VBA constant xlText as FileFormat …
    Thank you Marc for your reply, I tried as you suggest but same result:Attachment 751842

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Saving As Txt file adds double quotes


    As it well works as expected on my side so the bad in on your side …
    Follow the top page yellow banner to attach your workbook.

  5. #5
    Registered User
    Join Date
    05-17-2019
    Location
    Ro
    MS-Off Ver
    2016
    Posts
    22

    Re: Saving As Txt file adds double quotes

    Please find attached a sample file (some data has been modified because it contains confidential information) and also the .txt output file after saving as xlText format. I forgot to mention earlier all the data is located in first cell of the row.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Re: Saving As Txt file adds double quotes


    According to your attachment replace your SaveAs codeline with this code where F is an Integer and Rw a Range :

    PHP Code: 
            F FreeFile
            Open c00 
    ar(j1) & "_" ar(j2) For Output As #F
        
    For Each Rw In .UsedRange.Rows
            
    Print #F, Rw.Text
        
    Next
            Close 
    #F 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  7. #7
    Registered User
    Join Date
    05-17-2019
    Location
    Ro
    MS-Off Ver
    2016
    Posts
    22

    Re: Saving As Txt file adds double quotes

    Thank you very much Marc for your support. The code you provided is a breakthrough, but I have a small problem. Output files have no extensions and I can't open them. I need to rename all the files and put the .txt extension. Is there a solution here? If not, I can live with it , you've already saved me a lot of time.Attachment 751867

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Saving As Txt file adds double quotes


    Thanks for the rep' !

    Obviously Open c00 & ar(j, 1) & "_" & ar(j, 2) & " .txt" For Output As #F

  9. #9
    Registered User
    Join Date
    05-17-2019
    Location
    Ro
    MS-Off Ver
    2016
    Posts
    22

    Re: Saving As Txt file adds double quotes

    Quote Originally Posted by Marc L View Post

    Thanks for the rep' !

    Obviously Open c00 & ar(j, 1) & "_" & ar(j, 2) & " .txt" For Output As #F
    Thanks again Marc, it works great.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Saving as CSV with double quotes
    By papusale in forum Excel General
    Replies: 4
    Last Post: 01-21-2016, 11:10 AM
  2. Saving spreadsheet as text without unwanted double quotes (")
    By Tempe_VBA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2014, 10:14 PM
  3. [SOLVED] Double Quotes using Chr(34) and Extra Quotes when saving as text file
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-26-2013, 12:26 PM
  4. Using "Append", adds unwanted double quotes. How to remove them?
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 09:35 AM
  5. CSV File with Double quotes
    By anandmr65 in forum Excel General
    Replies: 0
    Last Post: 08-25-2006, 02:44 AM
  6. [SOLVED] CSV File with double quotes
    By NavSysEng in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2006, 12:20 PM
  7. double quotes when saving in CSV
    By Kozmos241 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2005, 05:06 PM

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