I try to save a word file as html using java. I save a word file as xml and its working for me
Runtime rt1 = Runtime.getRuntime();
rt1.exec("C:/Program Files/Microsoft Office/Office12/WINWORD.EXE /msaveasxml C:/myfolder/AB_00040.doc");
It save my doc file as xml file in the specific folder C:/myfolder and I view that xml file at C:/myfolder/AB_00040.xml
If i want to save the same file as html what can i do. Any one help
rt1.exec("C:/Program Files/Microsoft Office/Office12/WINWORD.EXE /msaveas??? C:/myfolder/AB_00040.doc");
Thanks in advance
解决方案
I found the answer with the hint of Zack Macomber i use a macro for convert word file to html file. I give the coding for that macro. Save the name of macro as "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
You can execute this macro by
Runtime rt1 = Runtime.getRuntime();
rt1.exec("C:/Program Files/Microsoft Office/Office12/WINWORD.EXE /msaveashtml C:/myfolder/AB_00040.doc");
saveasxml macro coding
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