Y
Yohancef Chin
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.
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.