asp.net calling mail merge

S

sf mong

I need help regarding Office Automation through ASP.NET.
I am trying to execute a Mail
Merge Document stored on the Server.

My code is as follows :-

Dim objword As New Word.Application()
Dim objDoc As New Word.Document()
Dim strLocation As String

Dim Filename As String
Filename = "http://manoj/wordtry/temp/ct.dot"
objDoc = objword.Documents.Add(Filename)

Try
With objDoc
..Visible = True
..Documents.Open(Filename)
..ActiveDocument.MailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument
..ActiveDocument.MailMerge.Execute()
End With
Catch ex As System.Exception
Response.Write("Error in Document Format" & ex.Message)
Finally
'objword.Quit()
End Try
End Sub

The same code snippet works fine on windows application
but in ASP.Net it does not work.

I get this Error

Server execution failed
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace
for more information about the error and where it
originated in the code.

Exception Details:
System.Runtime.InteropServices.COMException: Server
execution failed

Line 25: Dim objword As New Word.Application()
 
C

Cindy Meister -WordMVP-

Hi Sf,

I don't know why this would fail, except that generally,
Office application shouldn't run on a server (I'm not sure
if that's what you're trying to do). There's a KB article
about that, have you seen it?

In any case, I don't think the problem is
mailmerge-related, but more a ASP.NET question. Most people
who happen by this group don't use that environment...
I need help regarding Office Automation through ASP.NET.
I am trying to execute a Mail
Merge Document stored on the Server.

My code is as follows :-

Dim objword As New Word.Application()
Dim objDoc As New Word.Document()
Dim strLocation As String

Exception Details:
System.Runtime.InteropServices.COMException: Server
execution failed

Line 25: Dim objword As New Word.Application()

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top