By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Opening MS Word from a VB.NET ASP application

P: n/a
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.

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Here are a variety of ways to interact with Excel and Word:
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

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


"Yohancef Chin" <yc***@medstarholdings.com> wrote in message
news:09****************************@phx.gbl...
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.

Nov 18 '05 #2

P: n/a
Server-side office automation is not supported by Microsoft, in this article
you'll find the best way to configure the environment in this scenario:
INFO: Considerations for Server-Side Automation of Office

http://support.microsoft.com/default...b;EN-US;257757

These article explain how to create an office document server-side in a
supported way:
http://support.microsoft.com/default...b;en-us;288130

http://support.microsoft.com/default...b;EN-US;311461

http://support.microsoft.com/default...b;en-us;270906
These articles explain how to automate office application using client-side
code:
178222 HOWTO: Launch Word from Internet Explorer

http://support.microsoft.com/?id=178222

183284 INFO: CreateObject in VBScript

http://support.microsoft.com/?id=183284

209149 WD2000: How to Pass a Parameter to a Macro Using Automation

http://support.microsoft.com/?id=209149

285176 HOWTO: Automate Word to Perform a Client-Side Mail Merge Using XML
from

http://support.microsoft.com/?id=285176

HtH

Andrea

"Yohancef Chin" <yc***@medstarholdings.com> wrote in message
news:09****************************@phx.gbl...
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.

Nov 18 '05 #3

P: n/a
Hi,

As Andrea says, Server-side office automation is "doable" but really
not recommended.

You might want to look at XpertDoc, a fast and reliable technology
designed specifically for server-side, unattended creation of genuine
MS-Word documents.

It is very easy to set up, requiring little or no programming and
configuration.

You can download a free evaluation copy from www.xpertdoc.com

Hope this helps!
"Andrea D'Onofrio" <an******@microsoft.com> wrote in message news:<er**************@TK2MSFTNGP11.phx.gbl>...
Server-side office automation is not supported by Microsoft, in this article
you'll find the best way to configure the environment in this scenario:
INFO: Considerations for Server-Side Automation of Office

http://support.microsoft.com/default...b;EN-US;257757

These article explain how to create an office document server-side in a
supported way:
http://support.microsoft.com/default...b;en-us;288130

http://support.microsoft.com/default...b;EN-US;311461

http://support.microsoft.com/default...b;en-us;270906
These articles explain how to automate office application using client-side
code:
178222 HOWTO: Launch Word from Internet Explorer

http://support.microsoft.com/?id=178222

183284 INFO: CreateObject in VBScript

http://support.microsoft.com/?id=183284

209149 WD2000: How to Pass a Parameter to a Macro Using Automation

http://support.microsoft.com/?id=209149

285176 HOWTO: Automate Word to Perform a Client-Side Mail Merge Using XML
from

http://support.microsoft.com/?id=285176

HtH

Andrea

"Yohancef Chin" <yc***@medstarholdings.com> wrote in message
news:09****************************@phx.gbl...
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.

Nov 18 '05 #4

P: n/a
Yohancef

the access denied is a dcom thing with windows and you will have to go into
your dcomcnfg, click start run and type dcomcnfg.exe. Say No to the popups
that come up. Once the Windows Opens, find the listing for Microsoft Word
Document, Click Properties, and change the setting in the Identity Tab to
use an interactive user.

I am doing the same thing as you and have gotten really excellent advice
from this news group, look for my Name in the Postings and you
May see the Same Advice i got to fix this problem.
hope this helps

Samantha

"Yohancef Chin" <yc***@medstarholdings.com> wrote in message
news:09****************************@phx.gbl...
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.

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.