VBScript在未启用兼容模式的情况下将文档转换为DOCX

VBScript在未启用兼容模式的情况下将文档转换为DOCX,vbscript,ms-word,docx,doc,Vbscript,Ms Word,Docx,Doc,下面的VBScript将Word文档转换为DOCX: Set oFSO = CreateObject("Scripting.FileSystemObject") fullpath = oFSO.GetAbsolutePathName(Wscript.Arguments.Item(0)) justpath = Left(fullpath, InStrRev(fullpath, "\")) basename = oFSO.GetBaseName(fullpath) doxpath = justpat

下面的VBScript将Word文档转换为DOCX:

Set oFSO = CreateObject("Scripting.FileSystemObject")
fullpath = oFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
justpath = Left(fullpath, InStrRev(fullpath, "\"))
basename = oFSO.GetBaseName(fullpath)
doxpath = justpath & basename & ".docx" 
Set oWord = CreateObject("Word.Application")
Set doc = oWord.Documents.Open(fullpath)
doc.SaveAs2 doxpath, 16
doc.Close
oWord.Quit
Set oFSO = Nothing

但是,当我打开输出DOCX时,它在顶部显示“[兼容模式]”。在SaveAs2调用之前/期间/之后,我是否可以设置一些属性或方法来调用,这样就不会发生这种情况?

现在就可以了。谢谢托马拉克

Set oFSO = CreateObject("Scripting.FileSystemObject")
fullpath = oFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
justpath = Left(fullpath, InStrRev(fullpath, "\"))
basename = oFSO.GetBaseName(fullpath)
doxpath = justpath & basename & ".docx" 
Set oWord = CreateObject("Word.Application")
Set doc = oWord.Documents.Open(fullpath)
'FileFormat = wdFormatDocumentDefault = 16 = Word default document file format. For Word, this is the DOCX format.
'CompatibilityMode = wdCurrent = 65535 = Compatibility mode equivalent to the latest version of Word.
doc.SaveAs2 doxpath, 16, , , , , , , , , , , , , , , 65535
doc.Close
oWord.Quit
Set oFSO = Nothing

您看过
SaveAs2()
的文档了吗?对但这是一个VBA页面,兼容性选项位于一长串参数的末尾,无法在VBS中指定命名参数,我不想指定所有参数。您可以跳过不想提供的可选参数,只需编写相应数量的空逗号:
。SomeMethod RequiredArg,可选参数arg
.niice。我不知道。谢谢我倾向于定义
constwdcurrent=65535
,并在代码的其余部分使用常量。这可以保存解释性注释,并且比方法调用中的幻数更安全。