我發現扎克麥康伯的提示我使用宏轉換爲Word文件的HTML文件的答案。我給這個宏的編碼。保存宏的名稱爲 「saveashtml」
Sub saveashtml()
Dim xmlname As String
xmlname = ActiveDocument.FullName
xmlname = Replace(xmlname, ".docx", ".html", , , vbTextCompare)
xmlname = Replace(xmlname, ".doc", ".html", , , vbTextCompare)
ActiveDocument.SaveAs FileName:=xmlname, FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
Application.Quit
End sub
您可以通過
Runtime rt1 = Runtime.getRuntime();
rt1.exec("C:/Program Files/Microsoft Office/Office12/WINWORD.EXE /msaveashtml C:/myfolder/AB_00040.doc");
saveasxml宏編碼執行這個宏
Sub saveasxml()
Dim xmlname As String
xmlname = ActiveDocument.FullName
xmlname = Replace(xmlname, ".docx", ".xml", , , vbTextCompare)
xmlname = Replace(xmlname, ".doc", ".xml", , , vbTextCompare)
ActiveDocument.SaveAs FileName:=xmlname, FileFormat:=wdFormatFlatXML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
End Sub
我覺得這是更比Java的MS Word問題。你嘗試過「msaveashtml」嗎? –
這可能會幫助你... http://office.microsoft.com/en-us/word-help/command-line-switches-for-microsoft-office-word-2007-HP010164010.aspx –
這也是。 ..http://support.microsoft.com/kb/210565 –