Word宏返回有关工具语法的错误

时间:2019-01-08 19:54:03

标签: vba ms-word

由于某些原因,当我运行此VBA宏代码时:

Sub dor()

    Dim DocStats As String
    Dim MBTitle As String
    Dim J As Integer


    With Selection
    .WholeStory
    .LanguageID = wdEnglishUS
    .HomeKey Unit:=wdStory
    End With


    MBTitle = "Readability Statistics"
    DocStats = ""
    With ActiveDocument.Content
        For J = 1 To 10
            'DocStats = DocStats & .ReadabilityStatistics(J)
            'DocStats = DocStats & ": "
            DocStats = DocStats & .ReadabilityStatistics(J).Value
            DocStats = DocStats & vbCrLf
        Next J
    End With


    '~ Create a FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    '~ Provide file path
    outFile = "C:\Users\Dor\Desktop\UrisJobs\work_prod\docx\all_files\output\" & ActiveDocument.Name & ".txt"


    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")

    Dim objFile As Object
    Set objFile = fso.CreateTextFile(outFile, True, True)

    '~ Setting up file to write
    '~ Set objFile = objFSO.CreateTextFile(outFile, True)


    strComputer = "."


        'Wscript.Echo objFile.Name  'Commented out

        '~ Write to file
    objFile.WriteLine DocStats


    '~ Close the file
    objFile.Close


End Sub

我收到此错误:

  

“工具语法统计信息数组不能在包含多种语言格式的文档上运行”

我不知道为什么,但是对于某些文档,我的代码正在运行,对于某些文档-我遇到了此错误。

0 个答案:

没有答案