ASP.NET and creating a word document

From: Dave (david_at_revilloc.remove.this.bit.com)
Date: 01/25/05


Date: Tue, 25 Jan 2005 06:36:56 -0800

Hi all,

I have found this document to be able to create a word
doc from my ASP.NET.

http://support.microsoft.com/default.aspx?scid=kb;en-
us;316384

I am having some problems...

I am using C#, Word 2003 and Windows XP, though the
application will be an ASP.NET application.

First, the document says to add:
using Word = Microsoft.Office.Interop.Word;
however, this won't compile. It says that the namespace "
already has Word. A bit of research I did suggested to
remove this line, so I did and the project now compiles.

Now, when I run it, and click my linkbutton, I am getting
an error.

Exception Details: System.UnauthorizedAccessException:
Access is denied.

ASP.NET is not authorized to access the requested
resource. Consider granting access rights to the resource
to the ASP.NET request identity. ASP.NET has a base
process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application
is not impersonating. If the application is impersonating
via <identity impersonate="true"/>, the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the
authenticated request user.

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.

Source Error:

Line 194: Word._Application oWord;
Line 195: Word._Document oDoc;
Line 196: oWord = new
Word.Application();
Line 197: oWord.Visible = true;

 
the error being on line 196.

Note, I am not doing everything it says in the MS
document, i.e. I go up to and include oPara3, I don't
need tables, though saying that, this error is at the
point of creating the word document.

Please note: I am fairly new to .NET. I had never heard
of interop prior to trying to do this. I am also within a
Microsoft Content Management Server environment.

Thanks for any help you care to offer.

Best regards,
Dave Colliver.
http://www.FOCUSPortals.com - Franchise opportunities
available.