473,569 Members | 2,526 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 6107
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
11121
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...
1
1395
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...
4
1276
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...
3
2070
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...
1
1733
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...
0
1165
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...
0
1240
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...
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...
1
1873
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...
0
7614
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...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.