943,616 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1520
  • ASP.NET RSS
Apr 22nd, 2009
0

Error opening word file from Asp.net

Expand Post »
I am trying to opening Word file in asp.net application. I Try Following Code For That
ASP.NET Syntax (Toggle Plain Text)
  1. private Word.ApplicationClass WordApp = new Word.ApplicationClass();
  2. protected void Button1_Click(object sender, EventArgs e)
  3. {
  4. Installation.doc";
  5. object fileName = Server.MapPath("/WordSample/WordFiles/Test.doc");
  6. object readOnly = false;
  7. object isVisible = true;
  8.  
  9. object missing = System.Reflection.Missing.Value;
  10.  
  11. WordApp.Visible = true;
  12.  
  13. Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,
  14.  
  15. ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing,
  16.  
  17. ref missing, ref missing, ref missing, ref isVisible,ref missing,ref
  18.  
  19. missing,ref missing,ref missing);
  20.  
  21. aDoc.Activate();
  22.  
  23. WordApp.Selection.TypeText("Copyright C# Corner");
  24. WordApp.Selection.TypeParagraph();
  25. }

All this works fine in View In Browser, But when I publish that Page The file

not opening and on Click of Button, Browser running continuosly, but cant find file. Is this error with path or else?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vyasdev2005 is offline Offline
4 posts
since Oct 2008
Apr 22nd, 2009
0

Re: Error opening word file from Asp.net

change this line

ASP.NET Syntax (Toggle Plain Text)
  1.  
  2. object fileName = Server.MapPath("/WordSample/WordFiles/Test.doc");
to
ASP.NET Syntax (Toggle Plain Text)
  1.  
  2. object fileName = Server.MapPath("~") & "WordSample\WordFiles\Test.doc";
Reputation Points: 22
Solved Threads: 9
Junior Poster
ninjaimp is offline Offline
129 posts
since Apr 2008
Apr 23rd, 2009
0

Re: Error opening word file from Asp.net

I try that, but File Not Found error comes......
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vyasdev2005 is offline Offline
4 posts
since Oct 2008
Apr 23rd, 2009
0

Re: Error opening word file from Asp.net

TRY WITH BELOW LINE:
ASP.NET Syntax (Toggle Plain Text)
  1. object fileName = Server.MapPath("WordFiles") + "\\" + "Test.doc";
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009
May 6th, 2009
0

Re: Error opening word file from Asp.net

I tried this but unfortunately, this one also dont work
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vyasdev2005 is offline Offline
4 posts
since Oct 2008
May 18th, 2009
0

Re: Error opening word file from Asp.net

TRY TO WRITE THE VALUE OF Server.MapPath("WordFiles") then check with path then print whole file path then check with server.
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Hosting problem
Next Thread in ASP.NET Forum Timeline: Displaying Pages Dynamic to users





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC