469,898 Members | 1,945 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Getting proble to Open word document on server

Hi ,
I have write the following code to open word document on server

Expand|Select|Wrap|Line Numbers
  1. using Microsoft.Office.Interop.Word;
  2.  
  3.  string DocPath = System.Configuration.ConfigurationManager.AppSettings["VirtualDocPath"];
  4.  
  5.             ApplicationClass wordApp = new ApplicationClass();
  6.             string filePath = "";
  7.             filePath = DocPath + Session["username"] + "/" + DocFile.Value.ToString();
  8.             lblPath.Text = Server.MapPath("~/Document/" + Session["username"]) + "/" + DocFile.Value.ToString();
  9.             object file = filePath;
  10.             object readOnly = false;
  11.             object isVisible = true;
  12.             object nullobj = System.Reflection.Missing.Value;
  13.             wordApp.Visible = false;
  14.  
  15.             // here on Document.Open there should be 9 arg.
  16.             //Word.Document doc = new Document();
  17.             //Microsoft.Office.Interop.Word.Document doc;
  18.  
  19.             Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file,
  20.             ref nullobj, ref readOnly, ref nullobj, ref nullobj, ref nullobj,
  21.             ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
  22.             ref isVisible, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
  23.  
  24.  
  25.             // Here the word content is copeied into a string which helps to
  26.             // store it into textbox.
  27.             Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
  28.  
  29.             string m_Content = doc1.Content.Text;
  30.  
  31.             // the content is stored into the textbox.
  32.             if (sMode.Trim() == "ReadOnly")
  33.             {
  34.                 txtdocument.ReadOnly = true;
  35.                 btnSave.Visible = false;
  36.                 btnEsign.Visible = false;
  37.             }
  38.  
  39.             txtdocument.Text = m_Content;
  40.             doc.Close(ref nullobj, ref nullobj, ref nullobj);

This code is working fine on my local machine ond other local machine where Microsoft office 2007 is installed
but on my server I'm getting the following

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005


Can anyone give me solution of this error.

Thanks in advance

Saket
Sep 4 '09 #1
2 4224
Frinavale
9,735 Expert Mod 8TB
Is Microsoft office 2007 installed on the server?
Sep 4 '09 #2
i got the solution finally.
I have just given the full rights to the aspnet user on server to that particular folder where I have to keep my documents.
Apr 6 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Josh Asbury | last post: by
1 post views Thread by fab | last post: by
1 post views Thread by iwdu15 | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.