How can I export this string? Thanks for helping

M

Marc B.

Hi,

I work on a form in MSAccess to create KML files. I guess the following
problem is simple if u know what it is.

Can somebody help my to find out what I do wrong in my code?
I want to export data into a test.txt file. Anyway, my problem is that this
code exports the string with 2 double quotes instead of one.

here the code:
_________________________________________________________________________
Dim command As Variant
Dim strdateiname As String

command = "<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are useful!</h1><p><font
color=""red"">Text is <i>more readable</i> and <b>easier to write</b> when
you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
___________________________________________________________________________
This is the result in the test.txt file:

"<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are useful!</h1><p><font
color=""red"">Text is <i>more readable</i> and <b>easier to write</b> when
you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

---------------------------------------------------------------------------------------
When I use this code I get an error because I only use 1 double quote:

Dim command As Variant
Dim strdateiname As String

command = "<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are useful!</h1><p><font
color="red">Text is <i>more readable</i> and <b>easier to write</b> when you
can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
---------------------------------------------------------------------------------------
this is what my test.txt should contain after export:

<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are useful!</h1><p><font
color="red">Text is <i>more readable</i> and <b>easier to write</b> when you
can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>
 
K

Ken Snell

Change this line of code:

Write #1, command


to this:

Print #1, command
--

Ken Snell
http://www.accessmvp.com/KDSnell/


Marc B. said:
Hi,

I work on a form in MSAccess to create KML files. I guess the following
problem is simple if u know what it is.

Can somebody help my to find out what I do wrong in my code?
I want to export data into a test.txt file. Anyway, my problem is that
this code exports the string with 2 double quotes instead of one.

here the code:
_________________________________________________________________________
Dim command As Variant
Dim strdateiname As String

command = "<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color=""red"">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
___________________________________________________________________________
This is the result in the test.txt file:

"<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color=""red"">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

---------------------------------------------------------------------------------------
When I use this code I get an error because I only use 1 double quote:

Dim command As Variant
Dim strdateiname As String

command = "<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
---------------------------------------------------------------------------------------
this is what my test.txt should contain after export:

<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>
---------------------------------------------------------------------------------------

thanks for any help.

Marc B.
 
M

Marc B.

that was it,

thanks a lot Ken :)





Ken Snell said:
Change this line of code:

Write #1, command


to this:

Print #1, command
--

Ken Snell
http://www.accessmvp.com/KDSnell/


Marc B. said:
Hi,

I work on a form in MSAccess to create KML files. I guess the following
problem is simple if u know what it is.

Can somebody help my to find out what I do wrong in my code?
I want to export data into a test.txt file. Anyway, my problem is that
this code exports the string with 2 double quotes instead of one.

here the code:
_________________________________________________________________________
Dim command As Variant
Dim strdateiname As String

command = "<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color=""red"">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
___________________________________________________________________________
This is the result in the test.txt file:

"<?xml version=""1.0"" encoding=""UTF-8""?><kml
xmlns=""http://www.opengis.net/kml/2.2""><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color=""red"">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

---------------------------------------------------------------------------------------
When I use this code I get an error because I only use 1 double quote:

Dim command As Variant
Dim strdateiname As String

command = "<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>"

strdateiname = "z:\test.TXT"
Open strdateiname For Output As #1

Write #1, command
Close #1
---------------------------------------------------------------------------------------
this is what my test.txt should contain after export:

<?xml version="1.0" encoding="UTF-8"?><kml
xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>CDATA
example</name><description><![CDATA[<h1>CDATA Tags are
useful!</h1><p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>]]></description><Point><coordinates>102.595626,14.996729</coordinates></Point></Placemark></Document></kml>
---------------------------------------------------------------------------------------

thanks for any help.

Marc B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top