Problem with ActiveDocument when using Word in ASP.Net

G

Guest

All,

I'm using a word application in ASP.net (server side) to open an existing
document, do a mail merge on it and then serve the created document to the
client.

The problem I am having is when I open the word document using the
Word.Application and I then try to access the ActiveDocument property I get
an error message saying that 'This command is not available because no
document is open. '

I have tried the exact same code in Windows forms and it works fine.

The code is;
Dim wordDoc As Word.Document
Dim wordApp As New Word.Application

fileName = "c:\killian.doc"

'
----------------------------------------------------------------
wordDoc = wordApp.Documents.Open(fileName, missing, [readOnly],
missing, missing, missing, missing, missing, missing, missing, missing,
isVisible)

With wordApp.Application
.ActiveDocument.MailMerge.MainDocumentType = wdFormLetters

The code fails here with the error 'This command is not available because no
document is open. '

I can't figure out why this wont work. Thanks in advance for any help.

Killian
 
M

Martin Dechev

Hi,

From the top of my head - it may be that (1)there are not enough rights to
open the file or (2)the file is already opened in another instance or that
(3)there is some dialog box shown (which you have no way to see) and the
file isn't in fact opened. Try setting Application.DisplayAlerts to false to
prevent (3) at least.

Greetings
Martin
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top