0

We generate HTML from text in an Excel spreadsheet. The text contains unicode representations of international characters. When we use VBA to extract the text and output it to a file, it is written as ANSI (ASCII). Is there a way to preserve the unicode representation using VBA?

Bruce

Bruce
  • 2,230
  • 18
  • 34
  • 1
    VBA uses Unicode internally, so there shouldn't be any problem doing this in theory... can you insert a bit of the code you're using please? Especially the bit where you're writing the file. – Ant Jan 25 '10 at 16:08

1 Answers1

3

The default file writing mechanisms in VBA are ANSI (just like VB6).

You need to use a different method. One way is to use the FileSystemObject.

   Dim fso As Object, MyFile As Object
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", False,True) 'Unicode=True'
   MyFile.WriteLine("This is a test.")
   MyFile.Close
Community
  • 1
  • 1
MarkJ
  • 30,070
  • 5
  • 68
  • 111