Reputation: 47
Exception thrown every time in console application while running this simple code
Public Function convertWord(ByVal file As String, ByVal Path As String) As Integer
Dim convertObj As Microsoft.Office.Interop.Word.Application
Dim WordDoc As Microsoft.Office.Interop.Word.Document
Try
convertObj = New Microsoft.Office.Interop.Word.Application
WordDoc = New Microsoft.Office.Interop.Word.Document
WordDoc = convertObj.Documents.Open(Path)
WordDoc.ExportAsFixedFormat(file, WdExportFormat.wdExportFormatPDF)
Return 2
Catch ex As Exception
_checkLog("Originalna greška je : " & ex.Message & ex.StackTrace)
Return 5
End Try
End Function
If i use debug mode this function works perfect. Otherwise
Log check: 30.12.2015. 11:17:15 Originalna greška je : Object reference not set to an instance of an object. Line 34
Line 34>>>WordDoc = convertObj.Documents.Open(Path)
Upvotes: 0
Views: 138
Reputation: 2167
Open DCOM Config Settings:
1. Start -> dcomcnfg.exe
2. Computer
3. Local Computer
4. Config DCOM
5. Search for Microsoft Word 97-2003 Documents -> Properties
Tab Identity, change from Launching User to Interactive User.
Upvotes: 1