我在 Zack Macomber 的提示下找到了答案,我使用宏将 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