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 = Nothing
wordApp = Nothing

End Sub

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

End Class