ub ConvertWei()
'
' ConvertWei Macro
' Macro created 9/9/2002 by Michael A. Fuller
'
Dim uArray As Variant
Dim ufile, ucode
Set ufile = CreateObject("Scripting.FileSystemObject")
Set ucode = ufile.OpenTextFile("C:\Unicode\big5u2.txt", 1, 0, -1)
uArray = ucode.ReadAll
Dim ti, tlen, tv1, tv2, tchr1, tchr2, tadd, tindex, tcount
Dim tstring As String, ustring As Variant, uchar As Variant
tcount = 1
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Font.Name = "Chn FWeibei L5 TT"
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
While Selection.Find.Execute() = True
tcount = tcount + 1
ustring = ""
tstring = Selection.Text
tlen = Len(tstring)
ti = 1
While ti <= tlen
tchr1 = Mid(tstring, ti, 1)
tv1 = Asc(tchr1)
If tv1 < 160 Then
ustring = ustring + tchr1
Else
tchr2 = Mid(tstring, ti + 1, 1)
If tv1 > 249 Then
ustring = ustring + tchr1 + tchr2
Else
tv2 = Asc(tchr2)
If tv2 < 128 Then
tadd = tv2 - 64
Else
tadd = tv2 - 96
End If
If tv1 < 164 Then
tindex = 160 * (tv1 - 161) + tadd + 1
Else
tindex = 160 * (tv1 - 164) + 417 + tadd + 1
End If
uchar = Mid(uArray, tindex, 1)
ustring = ustring + uchar
End If
ti = ti + 1
End If
ti = ti + 1
Wend
Selection.Font.Name = "TSC FWeibei L5 TT"
Selection.TypeText (ustring)
Wend
ucode.Close
End Sub
Sunday, January 17, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment