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

Granting ASP.NET write access to a file

P: n/a
Hi

I'm trying to create a web form that will print a MS Word doc from the web form. I'm using VB.net.

This is the code example

Dim WordApp As New Word.Applicati
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
Dim thisDoc As New Word.Documen
thisDoc = WordApp.Documents.Ad
With thisDo
.Range.InsertAfter("Printing with Word"
.Paragraphs.Item(1).Range.Font.Bold = Tru
.Paragraphs.Item(1).Range.Font.Size = 1
.Range.InsertParagraphAfter(
.Paragraphs.Item(2).Range.Font.Bold = Fals
.Paragraphs.Item(2).Range.Font.Size = 1
.Range.InsertAfter("This is the first line of the test printout"
.Range.InsertParagraphAfter(
.Range.InsertAfter("and this is the second line of the test printout"
Tr
.PrintOut(True, True
Catch ex As Exceptio
MsgBox(ex.Message
End Tr
End Wit
WordApp.Quit(
End Su

It works when I run this in a Windows Application but when I run it in a webform I get an error that say's "ASP.NET is not authorized to access the requested resource

Then it tells me "To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I've tried this but there is no security tab in the properties page for MS Word, or for .doc file

In the past I've granted ASP.NET access to SQL server through the Enterprise Manager but i can't find anything like that for word

Does anyone know how Grant ASP.NET Access to MSword or other Office Components

Thank Yo

Tom C

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


P: n/a
It sounds like you're using Windows XP.
To enable the security tab you must disable simple file sharing.
To do this, open any windows explorer window and choose Folder Options from
the Tools dropdown menu.
Then go to the View tab.
Scroll to the bottom of the list and uncheck the Use Simple File Sharing
checkbox and click the OK button.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Tom C." <an*******@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
Hi,

I'm trying to create a web form that will print a MS Word doc from the web form. I'm using VB.net.
This is the code example:

Dim WordApp As New Word.Applicatio
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim thisDoc As New Word.Document
thisDoc = WordApp.Documents.Add
With thisDoc
.Range.InsertAfter("Printing with Word")
.Paragraphs.Item(1).Range.Font.Bold = True
.Paragraphs.Item(1).Range.Font.Size = 14
.Range.InsertParagraphAfter()
.Paragraphs.Item(2).Range.Font.Bold = False
.Paragraphs.Item(2).Range.Font.Size = 12
.Range.InsertAfter("This is the first line of the test printout") .Range.InsertParagraphAfter()
.Range.InsertAfter("and this is the second line of the test printout") Try
.PrintOut(True, True)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End With
WordApp.Quit()
End Sub
It works when I run this in a Windows Application but when I run it in a webform I get an error that say's "ASP.NET is not authorized to access the
requested resource"
Then it tells me "To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click
"Add" to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access."
I've tried this but there is no security tab in the properties page for MS Word, or for .doc files
In the past I've granted ASP.NET access to SQL server through the Enterprise Manager but i can't find anything like that for word.
Does anyone know how Grant ASP.NET Access to MSword or other Office Components?
Thank You

Tom C.

Nov 18 '05 #2

P: n/a
Thanks Stev

That worked, but I'm still having problem after problem getting this code to run
I'm using VS Studio 2003, IIS 5.1, and Office 97. Would you recommend upgrading somethin
or should I just keep plugging away

Tom
Nov 18 '05 #3

P: n/a
I'm glad that worked.
So what is the new problem you're having?

--
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Tom C." <an*******@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Thanks Steve

That worked, but I'm still having problem after problem getting this code to run. I'm using VS Studio 2003, IIS 5.1, and Office 97. Would you recommend upgrading something or should I just keep plugging away?

Tom

Nov 18 '05 #4

P: n/a
O.K

After I set winword to have access from ASPNET I went back and opened Visual Studio to try my web application but the web app wouldn't open because It said that IIS was not running. So I went into Administrative tools and double clicked the IIS Icon, but nothing happened. Then I tried to unload and reload IIS, but the computer kept freezing; I rebooted several times and tried again. Then I reformated the drive and loaded Windows XP from scratch, and then IIS. It worked fine. then I installed Visual Studio and tried to open a webApplication, it didn't open so I went to Administrative tools and Double clicked the IIS Icon, and nothing happened, and the computer freezes if I try to uninstall IIS

Tom
Nov 18 '05 #5

P: n/a
Yikes, that sounds like a hairy problem.
Is it just one particular web application that it refuses to open? Will it
open any other web applications?
If IIS won't run then clearly ASP.NET isn't going to run.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Tom C." <an*******@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
O.K.

After I set winword to have access from ASPNET I went back and opened Visual Studio to try my web application but the web app wouldn't open
because It said that IIS was not running. So I went into Administrative
tools and double clicked the IIS Icon, but nothing happened. Then I tried to
unload and reload IIS, but the computer kept freezing; I rebooted several
times and tried again. Then I reformated the drive and loaded Windows XP
from scratch, and then IIS. It worked fine. then I installed Visual Studio
and tried to open a webApplication, it didn't open so I went to
Administrative tools and Double clicked the IIS Icon, and nothing happened,
and the computer freezes if I try to uninstall IIS.
Tom

Nov 18 '05 #6

P: n/a
I had similar situation. Not exactly as you described but weird thing
started to happen when i gave permissions to run Excel from ASP.NET using
dcomcnfg.

I hope this link will help you
http://support.microsoft.com/default...;en-us;Q274696

George.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:Oc**************@tk2msftngp13.phx.gbl...
Yikes, that sounds like a hairy problem.
Is it just one particular web application that it refuses to open? Will it open any other web applications?
If IIS won't run then clearly ASP.NET isn't going to run.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Tom C." <an*******@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
O.K.

After I set winword to have access from ASPNET I went back and opened Visual Studio to try my web application but the web app wouldn't open
because It said that IIS was not running. So I went into Administrative
tools and double clicked the IIS Icon, but nothing happened. Then I tried

to unload and reload IIS, but the computer kept freezing; I rebooted several
times and tried again. Then I reformated the drive and loaded Windows XP
from scratch, and then IIS. It worked fine. then I installed Visual Studio
and tried to open a webApplication, it didn't open so I went to
Administrative tools and Double clicked the IIS Icon, and nothing happened, and the computer freezes if I try to uninstall IIS.

Tom


Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.