Thursday, 14 July 2011

Show a word document content in asp.net page

using Microsoft.Office.Interop.Word;
//fuction
  private void readFileContent(string path)

  {

       ApplicationClass wordApp = new ApplicationClass();

      object file = path;

      object nullobj = System.Reflection.Missing.Value;       

      Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(

      ref file, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj, ref nullobj);

      doc.ActiveWindow.Selection.WholeStory();

      doc.ActiveWindow.Selection.Copy();

      string sFileText = doc.Content.Text;

      doc.Close(ref nullobj, ref nullobj, ref nullobj);

      wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);       

      Response.Write(sFileText);

   }

No comments:

Post a Comment

Table Partitioning in SQL Server

  Table Partitioning in SQL Server – Step by Step Partitioning in SQL Server task is divided into four steps: Create a File Group Add Files ...