vbscript 检测文件名的期刊是否和文件里页眉页脚的期刊一致,提示询问期刊标识是否正确

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 检测文件名的期刊是否和文件里页眉页脚的期刊一致,提示询问期刊标识是否正确相关的知识,希望对你有一定的参考价值。

Sub CheckjournalNameConsist()
    Dim i As Integer
    Dim fso, f, jp, jo As Object
    Dim nr, aimT, Keys, value, value1, value2, norName, ISSN As String
    Dim json
    Dim myrange As New myrange
    Dim Rng, wrd As Range

    Set fso = CreateObject("Scripting.FileSystemObject")
    norName = NormalTemplate.Path & Application.PathSeparator & "journalNameAbbr.json"
    Set f = fso.OpenTextFile(norName)

    nr = f.readall
    f.Close

    ' Convert the string to JSON data

    Set json = CreateObject("Scripting.Dictionary")
    Set json = JsonConverter.ParseJson(nr)
    
    If InStr(ActiveDocument.name, "-") = 0 Then
        MsgBox "The document name must start with the journal name and split with  '-' "
         
    End If
    journalName = LCase(Left(ActiveDocument.name, InStr(ActiveDocument.name, "-") - 1))
    
    pageHeader = JsonConverter.ConvertToJson(json(journalName))
    pageHeader = Replace(pageHeader, ChrW(34), "")
    WordBasic.ViewheaderOnly
    ActiveWindow.ActivePane.View.NextHeaderFooter
    Selection.MoveEndUntil "2"
    If Trim(pageHeader) = Trim(Selection.Text) Then
         ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Else
         ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
         ActiveDocument.Paragraphs(1).Range.comments.Add ActiveDocument.Paragraphs(1).Range, "Please check if the journal name is the same as in the header and footer of the document"
    End If
    Selection.HomeKey
   MsgBox "Please confrim this Logo is correct"
End Sub

以上是关于vbscript 检测文件名的期刊是否和文件里页眉页脚的期刊一致,提示询问期刊标识是否正确的主要内容,如果未能解决你的问题,请参考以下文章