Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want server(IIS) to ceate a word doument and users can download this file BY ie.

i use the solutions of MS WORD AUTOMATIONS,the codes like below:

C#
using Word = Microsoft.Office.Interop.Word;
private Word.ApplicationClass oWordApplic;
private Word.Document oDoc;		

oWordApplic = new Word.ApplicationClass();
object missing = System.Reflection.Missing.Value;
oDoc = oWordApplic.Documents.Add(ref missing, ref missing,ref missing, ref missing);
oDoc.Activate();		
oWordApplic.Selection.TypeText("test");
oDoc.SaveAs("tes.doc", ref missing,ref missing, ref missing,ref missing,ref missing,ref missing,
				ref missing,ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

oWordApplic.Application.Quit(ref missing, ref missing, ref missing);




this codes works well on my local machine,but when i publish this asp.net project on the server, the code do not work AND there is no any prompt message or error message.

no file is created and no any alert message.

anyone can help me??






I find the cause of this problem!


in the web.config, if i set the <compilation debug="false">(release), the issue occurs

if I set the <compilation debug="true"> (debug), the programs works well.

but I do not know why? and I publish a debug version to the server ?

anyone can help me ???
Posted
Updated 4-Mar-13 2:13am
v3
Comments
David_Wimbley 3-Mar-13 23:18pm    
Stupid question, is word installed on the server running asp.net?
Raja Soosai 4-Mar-13 1:54am    
Provide proper permission to IIS to interact with COM Objects.

thanks for your help!

I find the cause of this problem!


in the web.config, if i set the <compilation debug="false"> (release), the issue occurs

if I set the <compilation debug="true"> (debug), the programs works well.

but I do not know why? and I publish a debug version to the server ?

anyone can help me ???
 
Share this answer
 
What you have written will run on server. Check if the file is created on server and placed in the folder where you wrote code for.
Since you are having a web application, user/client will not see anything on their side - error or prompt as the code written is not a client side.

Code above is to create a word document and save on server. Now, your steps should be to find the core issue:
1. Document created or not
2. Document downloaded to client or not

Check for 1 first, if there is any issue on creation, it should be captured by logs. May be insufficient security privilege to save a file in the folder designated.
If 1 is working fine, look at the code for 2. See if the file is picked from correct location to be passed to client or not. Go step wise and narrow down the issue to resolve. May be the filepath while picking for download is not correctly formed.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900