请参考:
'* +++++++++++++++++++++++++++++
'* Created By I LOVE YOU WORD!@ExcelHome 2006-3-15 19:13:11
'仅测试于System: Windows NT Word: 11.0 Language: 2052
'№ 0032^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Option Explicit
Sub Example()
Dim myString As String
myString = "朱(GE946)基总理二(GA996) (GA996)一年"
MsgBox GetUnicode(myString)
End Sub
'----------------------
Function GetUnicode(strText As String) As String
Dim myString As String, i As Integer, TF As Boolean
Dim intLenth As Integer, aChar As String
intLenth = VBA.Len(strText)
For i = 1 To intLenth
aChar = Mid(strText, i, 1)
If aChar = "(" Then TF = True: aChar = ""
If aChar = ")" Then
TF = False
myString = VBA.Replace(myString, " ", "")
myString = VBA.Mid(myString, 2, Len(myString) - 1)
GetUnicode = GetUnicode & Chr("&H" & myString)
myString = ""
ElseIf TF = True Then
myString = myString & aChar
Else
GetUnicode = GetUnicode & aChar
End If
Next
End Function |