?
Solved

Write to Microsoft Word DOC file from ASP.Net Application

Posted on 2005-03-08
11
Medium Priority
?
373 Views
Last Modified: 2013-11-25
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
Comment
Question by:jsm11482
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
11 Comments
 
LVL 11

Accepted Solution

by:
sachiek earned 2000 total points
ID: 13492604
Check out this article. They had expalined how about this word document in asp.net

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

Sachi
0
 

Author Comment

by:jsm11482
ID: 13502829
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
 
LVL 11

Expert Comment

by:sachiek
ID: 13503082
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:sachiek
ID: 13503084
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
 
LVL 11

Expert Comment

by:sachiek
ID: 13503088
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
 
LVL 11

Expert Comment

by:sachiek
ID: 13503091
Also they had refered to this url for a soultion.

http://www.dotnet247.com/247reference/msgs/22/110667.aspx
0
 

Author Comment

by:jsm11482
ID: 13608892
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
 

Author Comment

by:jsm11482
ID: 13613503
BYW the site is www.supertrition.com
0
 
LVL 11

Expert Comment

by:sachiek
ID: 13642638
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
 
LVL 11

Expert Comment

by:sachiek
ID: 13642655
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question