LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Exporting to .txt converts single quotes to double quotes

Andrew P. brought next idea :
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. I have tried coding this line as

= "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) &
"ISO-885h9-1" & Chr(34) & " ?"

and

= "<?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?

Thanks a lot
Andrew


Not exactly sure what you mean by
<snip Unfortunately excel 2007 is saving the following line:

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

I pasted this line into a cell and wrote the text file using:

WriteTextFileContents ActiveCell.Value, "C:\Test.txt"

Here's what I got when viewed in Notepad:

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

...which hasn't changed from what was entered in the cell.

Here's the procedure to write the text file:

Sub WriteTextFileContents(Text As String, FileName As String, Optional
AppendMode As Boolean = False)
' A reuseable procedure to write or append large amounts of data to a
text file

Dim iNum As Integer
Dim bIsOpen As Boolean

On Error GoTo ErrHandler
iNum = FreeFile()
If AppendMode Then Open FileName For Append As #iNum Else Open
FileName For Output As #iNum
'If we got here the file has opened successfully
bIsOpen = True

'Print to the file in one single step
Print #iNum, Text


ErrHandler:
'Close the file
If bIsOpen Then Close #iNum
If Err Then Err.Raise Err.Number, , Err.Description
End Sub 'WriteTextFileContents()

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double quotes when exporting to tab delimited file jjk98 Excel Discussion (Misc queries) 2 January 13th 10 01:53 PM
Double Quotes [email protected] New Users to Excel 2 July 20th 08 12:43 PM
Double Quotes PeterM Excel Discussion (Misc queries) 5 June 17th 08 05:12 PM
Double Quotes Ed Excel Programming 1 January 13th 04 01:13 AM
Double Quotes Ed Excel Programming 1 January 12th 04 09:18 PM


All times are GMT +1. The time now is 01:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"