View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Martin Brown Martin Brown is offline
external usenet poster
 
Posts: 230
Default Exporting to .txt converts single quotes to double quotes

On 25/05/2010 10:14, Andrew P. wrote:
Hi All

Im making a module that will create a new spreadsheet, populate it with some
fixed and variable values and save it as a text file. Unfortunately excel
2007 is saving the following line:

<?xml version="1.0" encoding="ISO-885h9-1" ?

as

"<?xml version=""1.0"" encoding=""ISO-885h9-1"" ?"

when I open it in wordpad.


That *is* the correct encoding of an ASCII text string in a .txt file!

The opening quote at the start and end of the string means that
internally every use of " must use an escape code. Excel chooses to use
"" for escaping in ". Other languages choose similar methods. When Excel
reads it back in then it will see the correct string data.

Otherwise strings would be ambiguous in their .txt representation. This
way you know that true end of string is a " not followed by another.

= "<?xml version=""1.0"" encoding=""ISO-8859-1"" ?"

and it looks fine in the spreadsheet its in, but always bad when it gets to
the .txt file. I also tried separating into separate cells and formatting the
cell as text. Any idea how to correct this?


There is nothing to correct. Excel for once is doing the right thing.

Regards,
Martin Brown