Connecting Tech Pros Worldwide Help | Site Map

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

Yohancef Chin
Guest
 
Posts: n/a
#1: Nov 18 '05
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.Application
Dim oDoc As Word.Document


'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add

I changed the sample code to the following:

Dim oWord As Word.ApplicationClass
Dim oDoc As Word.DocumentClass


'Start Word and open the document template.
oWord = New Word.ApplicationClass()
oWord.Visible = True
oDoc = oWord.Documents.Add

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

Access Denied

Exception Details: System.UnauthorizedAccessException:
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.ApplicationClass()

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.Office.Interop.Word.dll.

Any ideas?

Thanks.


Yuri Vanzine
Guest
 
Posts: n/a
#2: Nov 18 '05

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


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: "anonymous@discussions.microsoft.com"
<anonymous@discussions.microsoft.com> Sent: 12/3/2003
11:25:41 AM




Thanks Steve! This should get it started:

<script language="javascript">
var word = new ActiveXObject("Word.Application");
word.Visible = true;
word.Documents.Add("Normal", false, 0);
var range = word.ActiveDocument.Range(0, 0);
range.InsertBefore("hey testing this");
range.Font.Name = "Arial";
range.Font.Size = 24;
range.InsertParagraphAfter();
//var pause = 0;
//var nopause = 1;
//var wdDialogFileOpen = 80;
//var wdDialogToolsOptionsSpellingAndGrammar = 203;
//var dialog = word.Dialogs
(wdDialogToolsOptionsSpellingAndGrammar);
//var button = dialog.Show(1);

//word.ActiveDocument.CheckGrammar();
//word.ActiveDocument.CheckSpelling();
//word.ActiveDocument.SaveAs("Mydoc.txt", 4);
word.Quit();
</script>


[color=blue]
>-----Original Message-----
>Take a look at the client side example in this article[/color]
(near the end):[color=blue]
>http://www.aspnetpro.com/NewsletterA...003/09/asp2003[/color]
09so_l/asp200309so_l.asp[color=blue]
>
>The example uses Excel but it should still be helpful to[/color]
you.[color=blue]
>
>--
>I hope this helps,
>Steve C. Orr, MCSD, MVP
>http://Steve.Orr.net
>Hire top-notch developers at http://www.able-[/color]
consulting.com[color=blue]
>
>
>
>
>"Yuri Vanzine" <ypv@tft.com> wrote in message
>news:1a9f01c3b9bf$97c3a7a0$3101280a@phx.gbl...[color=green]
>> In asp we can run VBSCRIPT client-side which allows
>> for 'easy' :?) ms office COM object instantiation. How[/color][/color]
do[color=blue][color=green]
>> I access a Word object in ASP.NET on the client side?
>>
>> I would like to do spell checking from a web-based[/color][/color]
wysiwyg[color=blue][color=green]
>> editor and I am limited to using ms word from the[/color][/color]
client,[color=blue][color=green]
>> server-side word automation is out of the question for
>> several important reasons
>> (http://support.microsoft.com/default.aspx?
>>[/color][/color]
scid=http://support.microsoft.com:80/support/kb/articles/Q2[color=blue][color=green]
>> 57/7/57.asp&NoWebContent=1) . Although this
>> (http://www.codeproject.com/aspnet/wordapplication.asp)
>> article helps a little bit.
>>
>> Any help will be appreciated!
>>
>> Thanks,
>>
>> yv[/color]
>
>
>.
>[/color]
..

[color=blue]
>-----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.Application
> Dim oDoc As Word.Document
>
>
> 'Start Word and open the document template.
> oWord = CreateObject("Word.Application")
> oWord.Visible = True
> oDoc = oWord.Documents.Add
>
>I changed the sample code to the following:
>
> Dim oWord As Word.ApplicationClass
> Dim oDoc As Word.DocumentClass
>
>
> 'Start Word and open the document template.
> oWord = New Word.ApplicationClass()
> oWord.Visible = True
> oDoc = oWord.Documents.Add
>
>But when i build the solution it gives me the following
>error:
>
>Access Denied
>
>Exception Details: System.UnauthorizedAccessException:
>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.ApplicationClass()
>
>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.Office.Interop.Word.dll.
>
>Any ideas?
>
>Thanks.
>
>
>.
>[/color]
Yohancef
Guest
 
Posts: n/a
#3: Nov 18 '05

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


Thanks!
[color=blue]
>-----Original Message-----
>This is cut and paste from previous discussion.
>
>Rule of thumb: NO server-side ms office api calls[/color]
because[color=blue]
>it renders your server unstable and insecure. Plus
>Microsoft does not allow server-side thru very[/color]
restrictive[color=blue]
>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: "anonymous@discussions.microsoft.com"
><anonymous@discussions.microsoft.com> Sent: 12/3/2003
>11:25:41 AM
>
>
>
>
>Thanks Steve! This should get it started:
>
><script language="javascript">
> var word = new ActiveXObject("Word.Application");
> word.Visible = true;
> word.Documents.Add("Normal", false, 0);
> var range = word.ActiveDocument.Range(0, 0);
> range.InsertBefore("hey testing this");
> range.Font.Name = "Arial";
> range.Font.Size = 24;
> range.InsertParagraphAfter();
> //var pause = 0;
> //var nopause = 1;
> //var wdDialogFileOpen = 80;
> //var wdDialogToolsOptionsSpellingAndGrammar =[/color]
203;[color=blue]
> //var dialog = word.Dialogs
>(wdDialogToolsOptionsSpellingAndGrammar);
> //var button = dialog.Show(1);
>
> //word.ActiveDocument.CheckGrammar();
> //word.ActiveDocument.CheckSpelling();
> //word.ActiveDocument.SaveAs("Mydoc.txt", 4);
> word.Quit();
></script>
>
>
>[color=green]
>>-----Original Message-----
>>Take a look at the client side example in this article[/color]
>(near the end):[color=green]
>>http://www.aspnetpro.com/NewsletterA.../2003/09/asp20[/color][/color]
03[color=blue]
>09so_l/asp200309so_l.asp[color=green]
>>
>>The example uses Excel but it should still be helpful[/color][/color]
to[color=blue]
>you.[color=green]
>>
>>--
>>I hope this helps,
>>Steve C. Orr, MCSD, MVP
>>http://Steve.Orr.net
>>Hire top-notch developers at http://www.able-[/color]
>consulting.com[color=green]
>>
>>
>>
>>
>>"Yuri Vanzine" <ypv@tft.com> wrote in message
>>news:1a9f01c3b9bf$97c3a7a0$3101280a@phx.gbl...[color=darkred]
>>> In asp we can run VBSCRIPT client-side which allows
>>> for 'easy' :?) ms office COM object instantiation.[/color][/color][/color]
How[color=blue]
>do[color=green][color=darkred]
>>> I access a Word object in ASP.NET on the client side?
>>>
>>> I would like to do spell checking from a web-based[/color][/color]
>wysiwyg[color=green][color=darkred]
>>> editor and I am limited to using ms word from the[/color][/color]
>client,[color=green][color=darkred]
>>> server-side word automation is out of the question for
>>> several important reasons
>>> (http://support.microsoft.com/default.aspx?
>>>[/color][/color]
>scid=http://support.microsoft.com:80/support/kb/articles/[/color]
Q2[color=blue][color=green][color=darkred]
>>> 57/7/57.asp&NoWebContent=1) . Although this
>>>[/color][/color][/color]
(http://www.codeproject.com/aspnet/wordapplication.asp)[color=blue][color=green][color=darkred]
>>> article helps a little bit.
>>>
>>> Any help will be appreciated!
>>>
>>> Thanks,
>>>
>>> yv[/color]
>>
>>
>>.
>>[/color]
>..
>
>[color=green]
>>-----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?[/color][/color]
I[color=blue][color=green]
>>followed the instructions from a sample on the[/color][/color]
Microsoft[color=blue][color=green]
>>knowledge base but it only seems to work when creating[/color][/color]
a[color=blue][color=green]
>>VB.NET Windows .EXE, not an VB.NET ASP app.
>>
>> Imports Word=Microsoft.Office.Interop.Word
>>
>> Dim oWord As Word.Application
>> Dim oDoc As Word.Document
>>
>>
>> 'Start Word and open the document template.
>> oWord = CreateObject("Word.Application")
>> oWord.Visible = True
>> oDoc = oWord.Documents.Add
>>
>>I changed the sample code to the following:
>>
>> Dim oWord As Word.ApplicationClass
>> Dim oDoc As Word.DocumentClass
>>
>>
>> 'Start Word and open the document template.
>> oWord = New Word.ApplicationClass()
>> oWord.Visible = True
>> oDoc = oWord.Documents.Add
>>
>>But when i build the solution it gives me the following
>>error:
>>
>>Access Denied
>>
>>Exception Details: System.UnauthorizedAccessException:
>>Access is denied.
>>
>>The ASP.NET process is not authorized to access the
>>request. For security reasons the default ASP.NET[/color][/color]
process[color=blue][color=green]
>>is '{machinename}\ASPNET' which has limited[/color][/color]
privileges.[color=blue][color=green]
>>Consider granting access rights to the resource to the
>>ASP.NET process identity.
>>
>>Line 31: oWord = New Word.ApplicationClass()
>>
>>But it does not specify what it is trying to gain[/color][/color]
access[color=blue][color=green]
>>to. I tried giving the asp account admin rights just[/color][/color]
to[color=blue][color=green]
>>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.Office.Interop.Word.dll.
>>
>>Any ideas?
>>
>>Thanks.
>>
>>
>>.
>>[/color]
>.
>[/color]
Robert
Guest
 
Posts: n/a
#4: Nov 18 '05

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


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"
<anonymous@discussions.microsoft.com> wrote:
[color=blue]
>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.Application
> Dim oDoc As Word.Document
>
>
> 'Start Word and open the document template.
> oWord = CreateObject("Word.Application")
> oWord.Visible = True
> oDoc = oWord.Documents.Add
>
>I changed the sample code to the following:
>
> Dim oWord As Word.ApplicationClass
> Dim oDoc As Word.DocumentClass
>
>
> 'Start Word and open the document template.
> oWord = New Word.ApplicationClass()
> oWord.Visible = True
> oDoc = oWord.Documents.Add
>
>But when i build the solution it gives me the following
>error:
>
>Access Denied
>
>Exception Details: System.UnauthorizedAccessException:
>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.ApplicationClass()
>
>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.Office.Interop.Word.dll.
>
>Any ideas?
>
>Thanks.
>[/color]

Closed Thread