473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem with ActiveDocument when using Word in ASP.Net

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
Nov 18 '05 #1
1 2111
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
"Killian" <Ki*****@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bekil | last post by:
Thanks for your suggestion Murray Jack. I also record macro while doing it manually in word then I edit the macro to see the required code. Firstly I am creating a blank page. Secondly I go to...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
1
by: gaucho | last post by:
Hi all, I'm experiencing some problems when filling in bookmarks in word. With my first query (single row returned), no problem at all. Yet, with my new query (which now return 2 rows), i get...
1
by: Vijay | last post by:
Hi, I have to generate a word or rtf file on the fly whould have a Header and footer both but i m not able to include the header and footer in the document can anyone suggest me how can i do...
0
by: Killian | last post by:
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...
1
by: Josh Asbury | last post by:
Hi all - I am having troubles with implementing a CommandBar in Microsoft Word utilizing VB.net. My CommandBar appears when I start Word, but if I open an existing document, it does not appear....
1
by: jpr | last post by:
Friends, I am having problems in exporting data from my Access db to a word template. On my form I have a check box named check1. On my word template a have a box into which I need to export...
1
by: JustDucky | last post by:
Hi! I have a word template that utilizes a userform to gather information from the user and place it into specific Doc Variable locations within the form. If the user reopens the userform and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.