VBA: read/write chinese words  
Author Message
tsoetant





PostPosted: Visual Basic for Applications (VBA), VBA: read/write chinese words Top

Hi,
I want to read chinese, traditional chinese,korean,japanese words from word doc and write it into text file. But I have no luck up till now. I have no problems with french and german languages but these other 4 languages just can't be written into the text file. It'll leave some empty blank spaces into my text file.
Code so far:
Const ForWriting = 2
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\TCS.mtp", ForWriting)
Dim counter as integer
do while
lineArray = Split(theTable.Cell(caseStartRow, 2).Range.Text, Chr$(13))
objFile.writeLine (lineArray(counter))
counter = counter + 1
wend
objFile.close
Please help if there is anyone know how to solve the problem. Thank you so much!
Teddy


Microsoft ISV Community Center Forums1  
 
 
Derek Smyth





PostPosted: Visual Basic for Applications (VBA), VBA: read/write chinese words Top

Teddy,

It's more than likely that your writing your text file using ASCII encoding, think this is default on CreateTextFile. What your wanting to do is write the text file using Unicode. ASCII only contains characters in the latin character set, while Unicode contains all characters in all languages.

In the CreateTextFile method there is a boolean Unicode flag you can set.

This should sort the problem.