+ Reply to Thread
Results 1 to 4 of 4

CreateTextFile.WriteLine seems to insert double quotes at the beginning and end of ln

  1. #1
    Registered User
    Join Date
    05-10-2007
    Posts
    2

    CreateTextFile.WriteLine seems to insert double quotes at the beginning and end of ln

    I have an Excel spreadsheet with a button that execute a macro. The macro reads the rows one by one and creates a text string from the column. The string is written out to a text file.
    A text file generated by a user contains double quotes at the beginning and the end of each line in the output file. I opened the spread sheet on my machine and the double quotes do not show up.

    Sample code:

    Please Login or Register  to view this content.
    .... more....

    Sample output
    OK
    exec some_pkg.some_proc(....);
    exec some_pkg.some_proc(....);
    exec some_pkg.some_proc(......);
    Bad
    "exec some_pkg.some_proc(....);"
    "exec some_pkg.some_proc(....);"
    "exec some_pkg.some_proc(......);"
    Last edited by mudraker; 05-10-2007 at 06:00 PM.

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Have you tried printline instead of writeline?

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Zampano,

    Your problem isn't related to how the data is written to the file, but how it is converted. When importing a Text file to a worksheet using the TextToColumns method, you can specify how the text should appear by setting the TextQualifier argument.

    The general syntax is...
    Expression is a Range object
    expression.TextToColumns(Destination, DataType, TextQualifier, ConsecutiveDelimiter, Tab, Semicolon, Comma, Space, Other, OtherChar, FieldInfo, DecimalSeparator, ThousandsSeparator)

    The text qualifier can be one of the following XlTextQualifier constants: xlTextQualifierDoubleQuote, xlTextQualifierSingleQuote, or xlTextQualifierNone. The default value is xlTextQualifierDoubleQuote.

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 05-10-2007 at 08:19 PM.

  4. #4
    Registered User
    Join Date
    05-10-2007
    Posts
    2

    Thanks for your answers, it helps but still not clear

    The problem is that the spreadsheet has been working working for years and this week, one user generated the text files with double quotes.
    Again, the macro creates a string and then writes this string as a line to a text file. Somehow, when this user (only this user, and it happened only once) generates the text file with each line of text inside double quotes. Ex.

    This is output generated for years
    exec .....more text here
    exec .... more text here

    Happened only once
    "exec .....more text here"
    "exec .... more text here"

    Somehow this user's Excel installation treats string differently. The program (macro) behaves differently on his machine. It is most likely some Excel global setting.
    I have to reproduce the problem first in order to implement the correct solution.
    Any ideas appreciated...

    Thanks

+ 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