• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Write to Microsoft Word DOC file from ASP.Net Application

Hi, here is my situation.  I am currently working on an eCommerce site in which we need to generate an order form in Microsoft Word format every time an order is placed.  I have searched the web to try to find out how to do this but I have not had much luck.  Can someone please help me figure out how to write out to a DOC file that will open in MS Word.  I would like to be able to pass in some HTML perhaps and have the DOC writer object (or whatever) read in the HTML and save it as a DOC file.

I think that made sense, if not let me know. Please, this is VERY URGENT!!!!

Thank you,
Josh
0
jsm11482
Asked:
jsm11482
  • 7
  • 3
1 Solution
 
sachiekCommented:
Check out this article. They had expalined how about this word document in asp.net

http://www.codeproject.com/aspnet/wordapplication.asp

Sachi
0
 
jsm11482Author Commented:
Ok, almost there! I was able to edit and save a word doc using the above link, but when I tried to implement it in my asp.net app I get a Access Denied error when I attempt to Dim objApp = New Word.ApplicationClass.  Why is this?
-josh
0
 
sachiekCommented:
Did you checked those discussions below that article.

http://www.codeproject.com/aspnet/wordapplication.asp#xx994259xx

They had discussed about it and had came up with solutions.
Check out those.


Sachi
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sachiekCommented:
Solutions are


Try to set the security options in dcom configuration.
I solve my problem with this setting.
Go to control panel or start-run-type dcomcnfg
select component services-computers-mycomputer
select dcom configuration and then go for microsoftworddocument and set the security options for that by rightclick-properties.
add asp.netmachineaccount and set the permissions for it.
try this friend.
0
 
sachiekCommented:
Furthere in that discussions

Try this. Start...Run...DCOMCNFG.EXE (Since you're launching Word, which is
a COM component, .NET Interop uses DCOM).

In DCOMCNFG, find the application named 'Microsoft Word document'. (If you
have Windows XP, I think you will find it in Console
Root...Component Services...Computers...My Computer...DCOM Config.
Otherwise, look on the "Application" tab.)

On the properties window for 'Microsoft Word document', select the Security
tab and add the ASPNET user to the Launch and Access permissions list.

If you are not familiar with DCOMCNFG, please read the following article.

Q268550 HOWTO: Use DCOMCNFG for a VB DCOM Client/Server Application,
http://support.microsoft.com/support/kb/articles/q268/5/50.asp
0
 
sachiekCommented:
Also they had refered to this url for a soultion.

http://www.dotnet247.com/247reference/msgs/22/110667.aspx
0
 
jsm11482Author Commented:
Sorry ive been away from this question so long, my host has installed office on their server so i can access the COM Object, but now, when i get to the point in the ASP app where i load the template:

Dim objApp As New Word.ApplicationClass
Dim objDoc As Word.Document = objApp.Documents.Add(gobjSettings.GetValue("AppPath", GetType(String)) & "Documents\Invoice.dot")

I get a login popup, as if i was attempting to go to a secured site, and when i click cancel i get:
******************************************************************************************************************************

Server Error in '/' Application.
--------------------------------------------------------------------------------

Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[UnauthorizedAccessException: Access is denied.]
   SuperTrition.Components.Invoice.Create(Order oOrder)
   SuperTrition.Core.checkout.ProcessOrder(String sRefID)
   SuperTrition.Core.checkout.AuthorizeCard()
   SuperTrition.Core.checkout.btnPlaceOrder_Click(Object sender, EventArgs e)
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
******************************************************************************************************************************

My host has gone thru DCOMCONFIG and set all the settings.  What else could be the problem? This works just fine on my machine (win XP) but not on theirs (win 2003).

Thank you!
-Josh

PS I raised the points.
0
 
jsm11482Author Commented:
BYW the site is www.supertrition.com
0
 
sachiekCommented:
Can you check IIS out there in win2003 server?

Under your virtual directory look under "Directory Security"

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.

Sachi
0
 
sachiekCommented:
Probably you need to check this page and try out various solutions listed in this support page.

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

Sachi
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now