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

1
  • 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. Commented Jan 25, 2010 at 16:08

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.