VBA Macro to search a text string and replace with hyperlink works only with English text, but not Arabic

妖精的绣舞 提交于 2019-12-02 13:17:03

You don't provide the code you used to search an Arabic term but based on the word posted in the question the issue appears to be related to Arabic being RTL in a LTR document. I wasn't able to test with Arabic characters in the macro code - even following the instructions in the link you provide my VBA editor only displays ? - possibly because I don't have the Arabic IME installed...

In any case, I was able to get it to work using the decimal number representation of the Unicode characters. The trick is to put them in reverse order (RTL) so:

strSearch = ChrW(1603) & ChrW(1604) & ChrW(1605) & ChrW(1577) 
'instead of ChrW(1577) & ChrW(1605) & ChrW(1604) & ChrW(1603)

The request has been changed to allowing the decimal number to be provided as a character-delimited string value. This can be split into an array, which is looped to put each value into the ChrW function and these concatenated into the search string:

Dim strSearch As String, Word1 As String
Dim valWord1 As Variant
Dim i As Long
Word1 = "1603,1604,1605,1577"
valWord1 = Split(Word1, ",")
For i = LBound(valWord1) To UBound(valWord1)
    strSearch = strSearch & ChrW(valWord1(i))
Next
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!