Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File encoding problem


Hi,

My purpose is create a macro that writes a XML file.

I have created a file text with several -Print #, string - commands.
In fact, it is a text file with .xml extension, and I have put in th
first line the tag -<?xml version='1.0' encoding='*UTF-8*' ?-, becaus
I want this document to be encoded that way.

What happens is that I think that the way I create the file doesn't us
the UTF8 encoding, so when I try to open the XML file with Interne
Explorer I get an error (I use some special characters, as &iacute;
because there are problems with some characters.

I would like to know how to create a file with UTF-8 encoding, or th
other option would be how to change the encoding of an existing fil
(even better!). In both cases, I need to do all these thing via a
excel macro (vba).

I have spent several days surfing the web and I'm beginnig t
desperate!!!!

Thanks in advanc

--
anlana
-----------------------------------------------------------------------
anlanac's Profile: http://www.excelforum.com/member.php...fo&userid=2698
View this thread: http://www.excelforum.com/showthread.php?threadid=40195

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default File encoding problem

The following method should work:

Dim fso As FileSystemObject
Dim ts As TextStream

Set fso = New FileSystemObject
Set ts = fso.CreateTextFile("C:\myFile.xml")

ts.WriteLine "<? xml version = " & Chr(34) & "1.0" & Chr(34) & _
" encoding = " & Chr(34) & "UTF-8" & Chr(34) & " ?"

' Use the ts (TextStream object) to write the remaing stuff here

ts.Close
Set ts = Nothing
Set fso = Nothing

Using the TextStream instead of Print should fix the encoding. Also,
the Chr(34)'s are quotes. You can do this or double quotes, but I find
the double quotes hard to read.


----
Nick Hebb
BreezeTree Software
http://www.breezetree.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File encoding problem


Thanks for your response.

I have replaced the print statements with the Windows Scripting Runtime
commands (FileSystemObject ,writeline, etc) that you suggested.

Unfortunately, I still have the same problem (I have attached the
zipped xml file that causes my nightmares, just in case it would be
useful for any suggestion...)

At this point, I'm starting to think that maybe the reason of the
problem is not what I supose it was ...

Thanks in advance!


+-------------------------------------------------------------------+
|Filename: sumarias.zip |
|Download: http://www.excelforum.com/attachment.php?postid=3782 |
+-------------------------------------------------------------------+

--
anlanac
------------------------------------------------------------------------
anlanac's Profile: http://www.excelforum.com/member.php...o&userid=26987
View this thread: http://www.excelforum.com/showthread...hreadid=401953

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File encoding problem


Please I need help about subject shown above.

Thanks in advance to all of u!!!

Ani.


--
anlanac
------------------------------------------------------------------------
anlanac's Profile: http://www.excelforum.com/member.php...o&userid=26987
View this thread: http://www.excelforum.com/showthread...hreadid=401953

Reply
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
file conversion encoding error Kris Excel Discussion (Misc queries) 1 August 30th 08 06:00 AM
xls, txt encoding JU Excel Discussion (Misc queries) 0 December 19th 07 08:15 PM
File conversion-text encoding issue elhirsch Excel Discussion (Misc queries) 2 September 11th 06 03:19 PM
UTF-8 encoding CSV [email protected] Excel Discussion (Misc queries) 0 April 4th 06 02:33 AM
Choosing a file encoding in VBA Renaud Excel Discussion (Misc queries) 1 July 29th 05 05:46 AM


All times are GMT +1. The time now is 07:32 PM.

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"