473,715 Members | 4,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening MS Word from a VB.NET ASP Page Access Denied

Hi,

Being fairly new to .NET I am looking for a way to call
MS
Word from an event on a webform, and after the user is
finished save that created document to an SQL Server
database. Has anyone done this? Does it seem possible? I
followed the instructions from a sample on the Microsoft
knowledge base but it only seems to work when creating a
VB.NET Windows .EXE, not an VB.NET ASP app.

Imports Word=Microsoft. Office.Interop. Word

Dim oWord As Word.Applicatio n
Dim oDoc As Word.Document
'Start Word and open the document template.
oWord = CreateObject("W ord.Application ")
oWord.Visible = True
oDoc = oWord.Documents .Add

I changed the sample code to the following:

Dim oWord As Word.Applicatio nClass
Dim oDoc As Word.DocumentCl ass
'Start Word and open the document template.
oWord = New Word.Applicatio nClass()
oWord.Visible = True
oDoc = oWord.Documents .Add

But when i build the solution it gives me the following
error:

Access Denied

Exception Details: System.Unauthor izedAccessExcep tion:
Access is denied.

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

Line 31: oWord = New Word.Applicatio nClass()

But it does not specify what it is trying to gain access
to. I tried giving the asp account admin rights just to
test but that didnt work. I also lowered to security
settings on IE to test as well, and I gave the ASPNET
account full access to the
Microsoft.Offic e.Interop.Word. dll.

Any ideas?

Thanks.
Nov 18 '05 #1
3 6126
This is cut and paste from previous discussion.

Rule of thumb: NO server-side ms office api calls because
it renders your server unstable and insecure. Plus
Microsoft does not allow server-side thru very restrictive
licensing. You are limited to client-side activeX calls
from your browser like below. Check that out. Also read
the links I enclosed further down in the discussion.

Good luck,
Yuri
. Reply (E-mail) Forward (E-mail)

Subject: Re: Client-side Word Automation from asp.net
From: "an*******@disc ussions.microso ft.com"
<an*******@disc ussions.microso ft.com> Sent: 12/3/2003
11:25:41 AM


Thanks Steve! This should get it started:

<script language="javas cript">
var word = new ActiveXObject(" Word.Applicatio n");
word.Visible = true;
word.Documents. Add("Normal", false, 0);
var range = word.ActiveDocu ment.Range(0, 0);
range.InsertBef ore("hey testing this");
range.Font.Name = "Arial";
range.Font.Size = 24;
range.InsertPar agraphAfter();
//var pause = 0;
//var nopause = 1;
//var wdDialogFileOpe n = 80;
//var wdDialogToolsOp tionsSpellingAn dGrammar = 203;
//var dialog = word.Dialogs
(wdDialogToolsO ptionsSpellingA ndGrammar);
//var button = dialog.Show(1);

//word.ActiveDocu ment.CheckGramm ar();
//word.ActiveDocu ment.CheckSpell ing();
//word.ActiveDocu ment.SaveAs("My doc.txt", 4);
word.Quit();
</script>
-----Original Message-----
Take a look at the client side example in this article (near the end):http://www.aspnetpro.com/NewsletterA...003/09/asp2003 09so_l/asp200309so_l.a sp
The example uses Excel but it should still be helpful to you.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able- consulting.com

"Yuri Vanzine" <yp*@tft.com> wrote in message
news:1a******* *************** ******@phx.gbl. ..
In asp we can run VBSCRIPT client-side which allows
for 'easy' :?) ms office COM object instantiation. How do I access a Word object in ASP.NET on the client side?

I would like to do spell checking from a web-based wysiwyg editor and I am limited to using ms word from the client, server-side word automation is out of the question for
several important reasons
(http://support.microsoft.com/default.aspx?
scid=http://support.microso ft.com:80/support/kb/articles/Q2 57/7/57.asp&NoWebCon tent=1) . Although this
(http://www.codeproject.com/aspnet/wordapplication.asp)
article helps a little bit.

Any help will be appreciated!

Thanks,

yv

.

..

-----Original Message-----
Hi,

Being fairly new to .NET I am looking for a way to call
MS
Word from an event on a webform, and after the user is
finished save that created document to an SQL Server
database. Has anyone done this? Does it seem possible? I
followed the instructions from a sample on the Microsoft
knowledge base but it only seems to work when creating a
VB.NET Windows .EXE, not an VB.NET ASP app.

Imports Word=Microsoft. Office.Interop. Word

Dim oWord As Word.Applicatio n
Dim oDoc As Word.Document
'Start Word and open the document template.
oWord = CreateObject("W ord.Application ")
oWord.Visible = True
oDoc = oWord.Documents .Add

I changed the sample code to the following:

Dim oWord As Word.Applicatio nClass
Dim oDoc As Word.DocumentCl ass
'Start Word and open the document template.
oWord = New Word.Applicatio nClass()
oWord.Visible = True
oDoc = oWord.Documents .Add

But when i build the solution it gives me the following
error:

Access Denied

Exception Details: System.Unauthor izedAccessExcep tion:
Access is denied.

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

Line 31: oWord = New Word.Applicatio nClass()

But it does not specify what it is trying to gain access
to. I tried giving the asp account admin rights just to
test but that didnt work. I also lowered to security
settings on IE to test as well, and I gave the ASPNET
account full access to the
Microsoft.Offi ce.Interop.Word .dll.

Any ideas?

Thanks.
.

Nov 18 '05 #2
Thanks!
-----Original Message-----
This is cut and paste from previous discussion.

Rule of thumb: NO server-side ms office api calls becauseit renders your server unstable and insecure. Plus
Microsoft does not allow server-side thru very restrictivelicensing. You are limited to client-side activeX calls
from your browser like below. Check that out. Also read
the links I enclosed further down in the discussion.

Good luck,
Yuri
. Reply (E-mail) Forward (E-mail)

Subject: Re: Client-side Word Automation from asp.net
From: "an*******@disc ussions.microso ft.com"
<an*******@dis cussions.micros oft.com> Sent: 12/3/2003
11:25:41 AM


Thanks Steve! This should get it started:

<script language="javas cript">
var word = new ActiveXObject(" Word.Applicatio n");
word.Visible = true;
word.Documents. Add("Normal", false, 0);
var range = word.ActiveDocu ment.Range(0, 0);
range.InsertBef ore("hey testing this");
range.Font.Name = "Arial";
range.Font.Size = 24;
range.InsertPar agraphAfter();
//var pause = 0;
//var nopause = 1;
//var wdDialogFileOpe n = 80;
//var wdDialogToolsOp tionsSpellingAn dGrammar = 203; //var dialog = word.Dialogs
(wdDialogTools OptionsSpelling AndGrammar);
//var button = dialog.Show(1);

//word.ActiveDocu ment.CheckGramm ar();
//word.ActiveDocu ment.CheckSpell ing();
//word.ActiveDocu ment.SaveAs("My doc.txt", 4);
word.Quit();
</script>
-----Original Message-----
Take a look at the client side example in this article(near the end):
http://www.aspnetpro.com/NewsletterA.../2003/09/asp20 0309so_l/asp200309so_l.a sp

The example uses Excel but it should still be helpful to
you.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.c om


"Yuri Vanzine" <yp*@tft.com> wrote in message
news:1a****** *************** *******@phx.gbl ...
In asp we can run VBSCRIPT client-side which allows
for 'easy' :?) ms office COM object instantiation. Howdo I access a Word object in ASP.NET on the client side?

I would like to do spell checking from a web-basedwysiwyg editor and I am limited to using ms word from theclient, server-side word automation is out of the question for
several important reasons
(http://support.microsoft.com/default.aspx?

scid=http://support.microso ft.com:80/support/kb/articles/

Q2 57/7/57.asp&NoWebCon tent=1) . Although this
(http://www.codeproject.com/aspnet/wordapplication.asp) article helps a little bit.

Any help will be appreciated!

Thanks,

yv

.

..

-----Original Message-----
Hi,

Being fairly new to .NET I am looking for a way to call
MS
Word from an event on a webform, and after the user is
finished save that created document to an SQL Server
database. Has anyone done this? Does it seem possible?

Ifollowed the instructions from a sample on the Microsoftknowledge base but it only seems to work when creating aVB.NET Windows .EXE, not an VB.NET ASP app.

Imports Word=Microsoft. Office.Interop. Word

Dim oWord As Word.Applicatio n
Dim oDoc As Word.Document
'Start Word and open the document template.
oWord = CreateObject("W ord.Application ")
oWord.Visible = True
oDoc = oWord.Documents .Add

I changed the sample code to the following:

Dim oWord As Word.Applicatio nClass
Dim oDoc As Word.DocumentCl ass
'Start Word and open the document template.
oWord = New Word.Applicatio nClass()
oWord.Visible = True
oDoc = oWord.Documents .Add

But when i build the solution it gives me the following
error:

Access Denied

Exception Details: System.Unauthor izedAccessExcep tion:
Access is denied.

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

Line 31: oWord = New Word.Applicatio nClass()

But it does not specify what it is trying to gain accessto. I tried giving the asp account admin rights just totest but that didnt work. I also lowered to security
settings on IE to test as well, and I gave the ASPNET
account full access to the
Microsoft.Off ice.Interop.Wor d.dll.

Any ideas?

Thanks.
.

.

Nov 18 '05 #3
I ran into the same problem. As indicated by the error message, you
need to open Word from an account that has sufficient privileges on
the server machine.

Open the IIS manager and open the properties dialog for your web
directory. On the Directory Security tab click the Edit button for the
"Anonymous Access and Authentication Control" area.

Again click the Edit button under "Anonymous Access". This will give
you a dialog window where you can change the account to one that has
the correct level of permissions.

Robert

On Thu, 4 Dec 2003 09:51:09 -0800, "Yohancef Chin"
<an*******@disc ussions.microso ft.com> wrote:
Hi,

Being fairly new to .NET I am looking for a way to call
MS
Word from an event on a webform, and after the user is
finished save that created document to an SQL Server
database. Has anyone done this? Does it seem possible? I
followed the instructions from a sample on the Microsoft
knowledge base but it only seems to work when creating a
VB.NET Windows .EXE, not an VB.NET ASP app.

Imports Word=Microsoft. Office.Interop. Word

Dim oWord As Word.Applicatio n
Dim oDoc As Word.Document
'Start Word and open the document template.
oWord = CreateObject("W ord.Application ")
oWord.Visible = True
oDoc = oWord.Documents .Add

I changed the sample code to the following:

Dim oWord As Word.Applicatio nClass
Dim oDoc As Word.DocumentCl ass
'Start Word and open the document template.
oWord = New Word.Applicatio nClass()
oWord.Visible = True
oDoc = oWord.Documents .Add

But when i build the solution it gives me the following
error:

Access Denied

Exception Details: System.Unauthor izedAccessExcep tion:
Access is denied.

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

Line 31: oWord = New Word.Applicatio nClass()

But it does not specify what it is trying to gain access
to. I tried giving the asp account admin rights just to
test but that didnt work. I also lowered to security
settings on IE to test as well, and I gave the ASPNET
account full access to the
Microsoft.Offi ce.Interop.Word .dll.

Any ideas?

Thanks.


Nov 18 '05 #4

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

Similar topics

4
11133
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
1
1398
by: matthew rutherford via .NET 247 | last post by:
When I use the word automation object (registered word10 andusing the namespace in the .cs file) I get 'access denied' error when trying to run the thing on mylocal pc. I am using the ASPNET user. I have heard this is due to the ASPNET user never having openedword before and it is subsequently prompted by word for ausername and password dialog, which obviously ASPNET canthandle. I can actually hear the system beep as the dialog iscalled in...
4
1278
by: Mark | last post by:
I have been having a very difficult time trying to open a word document in ASP.NET. I have searched here and Google, with no success in finding answers to my problems. Although many articles say how easy it is, I cannot get it to work. My problem appears, at this point, to be that I keep getting an "Access Denied" message when I try to instantiate a new Word.ApplicationClass object. What can I do? The error page suggests setting the...
3
2078
by: Michael Tkachev | last post by:
Hi Everybody! I have a problem. When I get a HTML of my page that I'm rendering. I need to generate a word-document from a html. And than I have to send this word-document to the users through e-mail. So, how can I create a word-document if I have a html file? I created componet that allows do it. But this component doesn't work with Asp.Net. Exception shows error that Asp.net does't have a permitions for it. But it's a false. Asp.net...
1
1741
by: mr net | last post by:
Hi, I'm trying to write: Dim objWord As New Word.Application in the codebehind page but I'm getting the error written below. The question is what is the correct way to use word or any other office automation in asp.net applications? In the old (asp) days I used to write the code in a com. Today we can use the visual basic codebehind page but - is it the right way? should I change the ASP.NET permissions
0
1168
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
0
1245
by: sebnunes | last post by:
Hi all, I know this problem has been discussed many times but I've read different post about this problem and none could answer mine. I'm trying to use Word automation from an asp .net web page. I have the classic error Access Denied when the Word application object is instantiated. I have, as suggested in different posts, added the aspnet user to the
0
430
by: royan | last post by:
Help please! I have the same problem which this post http://groups.google.com/group/microsoft.public.vsnet.vstools.office/browse_thread/thread/91275741fa1e100f/164638c6d6ba3872?lnk=gst&q=System.UnauthorizedAccessException%3A+Access+is+denied.&rnum=1&hl=en#164638c6d6ba3872 When I deploy our ASP.NET Application web form to Windows server 2003 I got access deny error. We are using the Microsoft.Office.Interop.Word COM DLL. We need to read a...
1
1887
by: vin4tony | last post by:
Anyone plz help to open a word document using asp.net.I used a code ..but it shown access denied...Can anyone help me.. my error is Access is denied. 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. ASP.NET is not...
0
8823
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9047
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.