Getting proble to Open word document on server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saketmayur
    New Member
    • Sep 2009
    • 2

    Getting proble to Open word document on server

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

    Code:
    using Microsoft.Office.Interop.Word;
    
     string DocPath = System.Configuration.ConfigurationManager.AppSettings["VirtualDocPath"];
    
                ApplicationClass wordApp = new ApplicationClass();
                string filePath = "";
                filePath = DocPath + Session["username"] + "/" + DocFile.Value.ToString();
                lblPath.Text = Server.MapPath("~/Document/" + Session["username"]) + "/" + DocFile.Value.ToString();
                object file = filePath;
                object readOnly = false;
                object isVisible = true;
                object nullobj = System.Reflection.Missing.Value;
                wordApp.Visible = false;
    
                // here on Document.Open there should be 9 arg.
                //Word.Document doc = new Document();
                //Microsoft.Office.Interop.Word.Document doc;
    
                Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file,
                ref nullobj, ref readOnly, ref nullobj, ref nullobj, ref nullobj,
                ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
                ref isVisible, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
    
    
                // Here the word content is copeied into a string which helps to
                // store it into textbox.
                Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
    
                string m_Content = doc1.Content.Text;
    
                // the content is stored into the textbox.
                if (sMode.Trim() == "ReadOnly")
                {
                    txtdocument.ReadOnly = true;
                    btnSave.Visible = false;
                    btnEsign.Visible = false;
                }
    
                txtdocument.Text = m_Content;
                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
    Last edited by tlhintoq; Sep 4 '09, 09:46 AM. Reason: [CODE] ... your code here ... [/CODE] tags added
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Is Microsoft office 2007 installed on the server?

    Comment

    • saketmayur
      New Member
      • Sep 2009
      • 2

      #3
      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.

      Comment

      Working...