MS Word VBA to display Unicode strings

放肆的年华 提交于 2019-11-26 22:12:01

问题


We have some VBA code in MS Word 2010 which needs to display Persian (Farsi) words dynamically; in other words, depending on which buttons the user clicks on the VBA app window, we will display a different string of Persian.

The only way we discovered to do this was to use something like this and concatenate a very long string character by character: the ChrW(&633). Do you know another way we can do this? The strings will remain the same, but we need a couple of different ones. Can they be loaded from a file?

Your help is much appreciated. Thanks.


回答1:


Lets have an UTF-8 text file unicode.txt, a form UserForm1 with label Label1 and Button CommandButton1:

'ensure reference is set to Microsoft ActiveX DataObjects library 
'(the latest version of it) under "tools/references"

Dim adoStream As ADODB.Stream
Dim var_String As Variant

Set adoStream = New ADODB.Stream

adoStream.Charset = "UTF-8"
adoStream.Open
adoStream.LoadFromFile "unicode.txt"

Label1 = adoStream.ReadText

adoStream.Close


来源:https://stackoverflow.com/questions/17698260/ms-word-vba-to-display-unicode-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!