开发者

Extracting unicode text from Excel spreadsheet using VBA

开发者 https://www.devze.com 2022-12-18 05:24 出处:网络
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 A

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 A开发者_如何学CNSI (ASCII). Is there a way to preserve the unicode representation using VBA?

Bruce


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
0

精彩评论

暂无评论...
验证码 换一张
取 消