October 16th, 2003, 05:54 AM
Automate MS Word using httphandler?
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
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
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable