Automated MSWord using a httphandler?

bog123

New member
Joined
Aug 15, 2003
Messages
1
I would like to automate MS Word on a server using an httphandler. The idea is that an http request contains parameters in the querystring and these can be used to open a file on the server. The file can then be saved with a different extension and Word closed.

The word automation code is working fine from a console application, but I have a problem executing the automation code from within the httphandler. The httphandler has been configured in IIS, the web.config file and tested, no problems there.

I would appreciate any help in this matter or suggestions if there is another solution.

The code in question is below:

Public Class DocumentHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal objContext As HttpContext) Implements IHttpHandler.ProcessRequest

Dim wordApp As New Word.ApplicationClass()
Dim wordDoc As New Word.DocumentClass()

wordApp = New Word.Application()
wordDoc = New Word.Document()

wordApp.Visible = True

wordDoc = wordApp.Documents.Open("c:\temp\read.doc")
wordDoc.SaveAs(FileName:="c:\temp\read.rtf")

wordDoc.Close()
wordApp.Quit()
wordDoc = Nothing
wordApp = Nothing

End Sub

ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return True
End Get
End Property

End Class
 
Did you check the ntfs permissions and the .net clr permissions. They are tighter on calls from http and com than from the desktop. Also might want to try running the object as protected with an account just for its particular use.
 
Back
Top