我已经使用VB.Net (VS2010)开发了一个WinForm应用程序,并安装了Office 2010专业版,它运行在64位的Windows 7平台上。该程序打开.doc和.rtf格式的文档,并尝试将其保存为htm格式。我正在使用以下命令:
Dim sFilePath as String = "C:\ABC\file.doc"
Dim oApp As New Microsoft.Office.Interop.Word.Application
Dim oDoc As New Microsoft.Office.Interop.Word.Document
Dim sTempFileName As String = System.IO.Path.GetTempFileName()
oDoc = oApp.Documents.Open(sFilePath)
oApp.Visible = False
oDoc = oApp.ActiveDocument
oDoc.SaveAs2(sTempFileName, FileFormat:=WdSaveFormat.wdFormatHTML,CompatibilityMode:=Microsoft.Office.Interop.Word.WdCompatibilityMode.wdWord2007)
oDoc.Close()
oApp.Quit()
oDoc = Nothing
oApp = Nothing
在开发和运行时一切顺利,但是当我将其发布为离线安装,并在安装了Windows XP和Office 2007的客户端PC上部署时,它在oDoc.SaveAs2行上报错并崩溃。我已经谷歌了很多,但找不到解决方法。请有人尽快帮助我。