|
- Sub 测试()
- 'Call 转换编码(True) ' True:汉字转Unicode;False:Unicode转汉字
- Call 转换编码(False) ' True:汉字转Unicode;False:Unicode转汉字
- End Sub
- Private Sub 转换编码(ChangeType As Boolean)
- Selection.HomeKey unit:=wdStory
- With Selection.Find
- .ClearFormatting
- .Replacement.ClearFormatting
- .Text = IIf(ChangeType, "[!^1-^127]", "\{[\+\-][0-9]{4,5}\}")
- .Forward = True
- .Wrap = wdFindContinue
- .MatchWildcards = True
- .Format = False
-
- Do While .Execute
- With Selection.Range
- If ChangeType Then
- .Text = "{" & IIf(AscW(.Text) > 0, "+", "") & AscW(.Text) & "}"
- Else
- .Text = ChrW(Val(Mid(.Text, 2, Len(.Text) - 2)))
- End If
- End With
- Loop
- .ClearFormatting
- .Replacement.ClearFormatting
- End With
- End Sub
复制代码 |
|