vbscript 单个单词查缩写

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 单个单词查缩写相关的知识,希望对你有一定的参考价值。

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

以上是关于vbscript 单个单词查缩写的主要内容,如果未能解决你的问题,请参考以下文章

vbscript MM功能优化:速度,无限缩写

vbscript 批量改缩写

vbscript 检测数字和单位之间是否有空格;单位是否缩写

vbscript 12.检查作者贡献部分,作者名缩写是否跟前文部分作者名对应(名称缩写与前面部分的名称不一致)

使用VBScript控制Microsoft单词选项

vbscript 单词get_title11