Hello,
I've added an action in my asp.net website which allows the user to generate some doc and xls documents based on templates (a dot file for Word and a xls one for Excel).
I worked since the end of last week but I don't understand why, now, it doesn't work anymore and I would like to have your advices.
Here is the context :
First of all, you should know that it works perfectly on localhost but on IIS, over the Web, no way, no document is generated.
Here, it does not work because of the oDoc whish is nothing. But even before this problem, I had another. In the processus list, WINWORD.EXE was never killed. Any idea ? I think I have properly closed the document don't I ?
Now, on the server side :
Microsoft Office 2003 is properly installed (Excel and Word only) with a legal licence bought by my company.
- I work on IIS 6 so i gave to the user NETWORK_SERVICE all access rights to drive Office (in the DCOM configuration).
- I've added the Microsoft.Office.Interop.Excel/Word references to the project and I work with it without any problems.
- In the applications events viewer, I've seen some warnings from MsiInstaler with codes 1004 and 1015. They said that a key was not found in the regedit for the user NETWORK_SERVICE. So i added the right keys to the NETWORK_SERVICE SID (S-1-5-20).
- It still does not work and I don't know elsewhere I could search.
Hoping You'll be of great advice for me... Thank you
I've added an action in my asp.net website which allows the user to generate some doc and xls documents based on templates (a dot file for Word and a xls one for Excel).
I worked since the end of last week but I don't understand why, now, it doesn't work anymore and I would like to have your advices.
Here is the context :
First of all, you should know that it works perfectly on localhost but on IIS, over the Web, no way, no document is generated.
VB.NET:
' Here the code to export the user data in a Word document
Public Sub export()
oWord = New Word.Application
Dim missing As Object = System.Reflection.Missing.Value
' _template_path is a string with the absolute path to the template file (the dot one). I've verified : the path is correct.
If (File.Exists(Me._template_path)) Then
Dim oDoc As Word.Document = oWord.Documents.Add(Template:=Me._template_path)
' Whatever I make, here, oDoc = nothing and I don't know why. It is the main source of problems.
' Here, I call a method which replaces bookmarks in the dot file by the user data values
intermediariesExportOperations()
' Try to save the document but it's not easy 'cause the oDoc is nothing...
If Not File.Exists(_destination_path) Then
Try
oDoc.SaveAs(_destination_path)
Catch ex As NullReferenceException
Debug.WriteLine(ex.Message)
End Try
Else
' Here we change the document name by "name(1).doc" or "name(2).doc", etc...
Dim cpt As Int16 = 2
While (File.Exists(Me._destination_path.Replace(".doc", "(" & cpt & ").doc")))
cpt += 1
End While
oDoc.SaveAs(Me._destination_path.Replace(".doc", "(" & cpt & ").doc"))
Me._file_name.Replace(".doc", "(" & cpt & ").doc")
End If
' Try to close the document
Try
oDoc.Close()
Catch ex As NullReferenceException
Debug.WriteLine(ex.Message)
End Try
oWord.Quit(missing, missing, missing)
ReleaseComObject(oWord)
oWord = Nothing
End If
End Sub
Here, it does not work because of the oDoc whish is nothing. But even before this problem, I had another. In the processus list, WINWORD.EXE was never killed. Any idea ? I think I have properly closed the document don't I ?
Now, on the server side :
Microsoft Office 2003 is properly installed (Excel and Word only) with a legal licence bought by my company.
- I work on IIS 6 so i gave to the user NETWORK_SERVICE all access rights to drive Office (in the DCOM configuration).
- I've added the Microsoft.Office.Interop.Excel/Word references to the project and I work with it without any problems.
- In the applications events viewer, I've seen some warnings from MsiInstaler with codes 1004 and 1015. They said that a key was not found in the regedit for the user NETWORK_SERVICE. So i added the right keys to the NETWORK_SERVICE SID (S-1-5-20).
- It still does not work and I don't know elsewhere I could search.
Hoping You'll be of great advice for me... Thank you