Error opening word file from Asp.net

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 3
Reputation: vyasdev2005 is an unknown quantity at this point 
Solved Threads: 0
vyasdev2005 vyasdev2005 is offline Offline
Newbie Poster

Error opening word file from Asp.net

 
0
  #1
Apr 22nd, 2009
I am trying to opening Word file in asp.net application. I Try Following Code For That
  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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 114
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

Re: Error opening word file from Asp.net

 
0
  #2
Apr 22nd, 2009
change this line

  1.  
  2. object fileName = Server.MapPath("/WordSample/WordFiles/Test.doc");
to
  1.  
  2. object fileName = Server.MapPath("~") & "WordSample\WordFiles\Test.doc";
Please mark this post as 'Solved' if it has helped and fixed your issue.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: vyasdev2005 is an unknown quantity at this point 
Solved Threads: 0
vyasdev2005 vyasdev2005 is offline Offline
Newbie Poster

Re: Error opening word file from Asp.net

 
0
  #3
Apr 23rd, 2009
I try that, but File Not Found error comes......
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 217
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 32
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training

Re: Error opening word file from Asp.net

 
0
  #4
Apr 23rd, 2009
TRY WITH BELOW LINE:
  1. object fileName = Server.MapPath("WordFiles") + "\\" + "Test.doc";
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: vyasdev2005 is an unknown quantity at this point 
Solved Threads: 0
vyasdev2005 vyasdev2005 is offline Offline
Newbie Poster

Re: Error opening word file from Asp.net

 
0
  #5
May 6th, 2009
I tried this but unfortunately, this one also dont work
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 217
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 32
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training

Re: Error opening word file from Asp.net

 
0
  #6
May 18th, 2009
TRY TO WRITE THE VALUE OF Server.MapPath("WordFiles") then check with path then print whole file path then check with server.
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC