我想根據Word安裝版本保存Word文檔;保存Word文檔
如果是Word 2003(適當的版本號是11),則使用DOC
擴展名。
如果Word版本高於2003,則使用DOCX
擴展名。
的差異反映在發送給SaveAS
方法的第二個參數:
object fileFormat = GraphDocsSettings.Default.WordInstalledVersion > 11.0?
WdSaveFormat.wdFormatXMLDocument : WdSaveFormat.wdFormatDocument;
wordDoc.SaveAs(ref outputFile, fileFormat, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
然而,當使用Interop.Word 11.0我得到以下錯誤:
Microsoft.Office.Interop.Word.WDSaveFormat does not contain a definition for wdFormatXMLDocument.
任何想法?
對此接受答案的看了這麼張貼http://stackoverflow.com/questions/3266675/how-to-detect-installed-version-of-ms-office –
@PaulZahra,謝謝,我已經知道了什麼是安裝的版本。 – user3165438