我已成功将单词doc转换为pdf - 但我无法让winword流程结束。
Dim wordApplication As Object = New Microsoft.Office.Interop.Word.Application
Dim wordDocument As Object
wordApplication.displayalerts = Word.WdAlertLevel.wdAlertsNone
wordDocument = New Microsoft.Office.Interop.Word.Document
'wordDocument = Nothing
Dim outputFilename As String
Dim filename As String
filename = "c:\TestInvoice.doc"
Try
wordDocument = wordApplication.Documents.Open(filename, ReadOnly:=False)
outputFilename = System.IO.Path.ChangeExtension(filename, "pdf")
If Not wordDocument Is Nothing Then
wordDocument.ExportAsFixedFormat(outputFilename, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, False, Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument, 0, 0, Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent, True, True, Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, True, True, False)
End If
'Threading.Thread.Sleep(3000)
If File.Exists(System.IO.Path.ChangeExtension(filename, "pdf")) Then
MessageBox.Show(System.IO.Path.ChangeExtension(filename, "pdf"))
End If
'wordDocument = Nothing
'wordApplication.Documents(filename).Close(Word.WdSaveOptions.wdDoNotSaveChanges)
'wordDocument.dispose()
'wordApplication.quit(False)
wordDocument.close()
wordApplication.application.quit(False)
wordApplication = Nothing
我已经尝试了很多东西,过去几天一直在摸不着头脑 - 你能指出我正确的方向吗?
答案 0 :(得分:0)
您是否尝试过使用声明?
尝试将所有内容包装在其中。
load_model