Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation 1

Status
Not open for further replies.

Fubear

IS-IT--Management
Sep 11, 2002
299
GB
I am trying to write an ASP.NET page that takes the values submit from one form, inserts them into a Word .DOT template, and then emails the template to an email address.

My first problem is I cant seem to get the webserver to load word:

---
Line 20: private void Page_Load(object sender, System.EventArgs e) {
Line 21: Word.Application App = new Word.Application();
Line 22: }

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.UnauthorizedAccessException: Access is denied.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.
---

I have added the ASPNET account to the administrators group, and I have IIS running locally on my laptop for development purposes, so Office is definately installed.

Can anyone shed some light on this problem?

Also any other help/tutorials on doing what I am trying to do would be appreciated.
 
Additionally, I have seen referances to the code:

App.Application.Quit(ref missing, ref missing, ref missing);

compiling this code gives me:
The name 'missing' does not exist in the class or namespace 'MyProject.WebForm1'

Help?
 
Hi Fubear

I have encountered a very similar problem recently with Excel Automation. Here is the thread i posted here... thread855-621893

The official line from M$oft goes roughly.....

"Microsoft do not reccomend or support office automation through IIS. This is due to a number of features which can cause the process to fail e.g. If a word process caused an alert message box there is no way in which the automated process can clear this box causing the server to hang...."

...blah blah. suffice to say MS don't want you to and won't help you with this!

The solution i ended up using was to change the response type to "application/vnd.ms-excel"....this worked well for me and I suspect that "application/vnd.ms-word" will work equally well though i havent tried it. You can just create an HTML page with the response type above and it should open in word fairly true to format.

If you wish to pursue the server automation approach your problem maybe that you need to give appropriate DCOM launch and access permissions to the aspnet account...run "dcomcnfg" on the server and locate word in the application list and click the properties button - is all fairly self explantory...

Good luck, hope this helps to some extent.

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Bugger!

Ok, scratch that idea... it wasnt too important anyway.
 
Fubear...any luck with integrating data with WORD?

dlc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top