Application.Options.DefaultHighlightColorIndex = wdBrightGreen
Dim i As Integer
Dim fso, f, jp, jo As Object
Dim nr, aimT, Keys, value, norName As String
Dim value1 As String
Dim nowT As String
Set fso = CreateObject("Scripting.FileSystemObject")
norName = NormalTemplate.Path & Application.PathSeparator & "abbreviation.json"
Set f = fso.OpenTextFile(norName)
nr = f.readall
f.Close
Set myrange = ActiveDocument.Range(Selection.Range.End, ActiveDocument.Range.End)
aimT = FunctionGroup.convertUpper(Selection.Words(1).Text)
Set jp = New JsonParser
Set jo = jp.Decode(nr)
Keys = jp.EnumKeys(jo)
Dim str As String
value = jp.GetValue(jo, aimT)
If value = "n.a." Then
MsgBox "this word no abbreviation"
Exit Sub
End If
If value = "" Then
For i = Len(aimT) To 3 Step -1
value = jp.GetValue(jo, Left(aimT, i) + "-")
value1 = jp.GetValue(jo, Left(aimT, i))
If value1 <> "" Then
nowT = FunctionGroup.convertUpper(value1)
GoTo kr
End If
If value <> "" Then
nowT = FunctionGroup.convertUpper(CStr(value))
GoTo kr
End If
Next
MsgBox "can't find this word abbreviation"
Exit Sub
Else
nowT = FunctionGroup.convertUpper(CStr(value))
End If
kr:
If nowT = "N.a." Then
MsgBox "this word no abbreviation"
Else
Selection.Words(1).Text = nowT + " "
End If