vba - 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
我收到此错误:
“工具语法统计数组不能在包含多于一种语言格式的文档上运行”
我不知道为什么,但是对于某些文档,我的代码正在运行,而对于某些文档,我收到了这个错误。
解决方案
推荐阅读
- botframework - 从 Angular 调用我的 .NET Core Teams 机器人
- css - 非常简单的从左到右的 CSS 动画
- html - 如何使用 Ionic 实现夹入/夹出?
- spring-data-jpa - 弹簧数据 JPA。在子表中插入记录时发生异常时父表数据不会回滚
- azure-active-directory - Azure Active Directory 阻止程序 - 策略行为
- javascript - javascript对象中具有相同值的多个键
- node.js - Google Calendar API - 如何使用 NodeJS REST API 插入新事件
- javascript - 反应中地图功能的数组
- java - Selenium 不能仅在 Chrome 上以 iframe 中的 div 为目标
- javascript - JavaScript Array.filter uniqes 并且不阻塞 UI