Abs*_*the 4 vba ms-word word-vba
我正在尝试进行保存 - 与Word 2016中的以下代码一样:
Dim doc As Word.Document
Dim fpFile as string
Set doc = ActiveDocument
fpFile = doc.Path & "\" & doc.Name
doc.SaveAs Filename:=Left(fpFile, Len(fpFile) - 4) & "docx", FileFormat:=wdFormatDocument
Run Code Online (Sandbox Code Playgroud)
使用Left和Len函数的My Filename参数求值为:
C:\ Users\My Name\Documents\My Company\My Client\test folder\HeaderTemplate.docx
这对我来说很好,但我收到错误6294:SaveAs行上的'不兼容的文件类型和文件扩展名'.
我已经尝试将Filename首先放入一个字符串变量,我尝试了SaveAs2方法,两者都有相同的结果.我想保存为标准的非宏启用的docx文件.
有任何想法吗?
谢谢.
arc*_*nct 12
wdFormatDocument
是的.doc
,
wdFormatXMLDocument
是 .docx
来自MSDN(适用于Office 2007):
Name Value Description
wdFormatDocument 0 Microsoft Office Word format.
wdFormatDOSText 4 Microsoft DOS text format.
wdFormatDOSTextLineBreaks 5 Microsoft DOS text with line breaks preserved.
wdFormatEncodedText 7 Encoded text format.
wdFormatFilteredHTML 10 Filtered HTML format.
wdFormatHTML 8 Standard HTML format.
wdFormatRTF 6 Rich text format (RTF).
wdFormatTemplate 1 Word template format.
wdFormatText 2 Microsoft Windows text format.
wdFormatTextLineBreaks 3 Windows text format with line breaks preserved.
wdFormatUnicodeText 7 Unicode text format.
wdFormatWebArchive 9 Web archive format.
wdFormatXML 11 Extensible Markup Language (XML) format.
wdFormatDocument97 0 Microsoft Word 97 document format.
wdFormatDocumentDefault 16 Word default document file format. For Microsoft Office Word 2007, this is the DOCX format.
wdFormatPDF 17 PDF format.
wdFormatTemplate97 1 Word 97 template format.
wdFormatXMLDocument 12 XML document format.
wdFormatXMLDocumentMacroEnabled 13 XML document format with macros enabled.
wdFormatXMLTemplate 14 XML template format.
wdFormatXMLTemplateMacroEnabled 15 XML template format with macros enabled.
wdFormatXPS 18 XPS format.
Run Code Online (Sandbox Code Playgroud)