Friday, March 16, 2012

open a word document inside web browser

I need to open a microsoft word document inside the web browser page.I use the following code but it opens a word document just like when u open it in windows.

what should I do?

publicvoid Open(string strFileName)

{

try

{

object fileName = strFileName;

object readOnly1 =false;

object isVisible =true;

object missing = System.Reflection.Missing.Value;

oDoc = wordApp.Documents.Open(ref fileName,ref missing,ref readOnly1,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref isVisible,ref missing,ref missing,ref missing,ref missing);

oDoc.Activate();

}

catch (System.Runtime.InteropServices.COMException ex)

{

string s = ex.Message;int n = ex.ErrorCode;

}

}

protectedvoid btnExisting_Click(object sender,EventArgs e)

{

WordAppClass test =newWordAppClass();

string tempaltePath =ConfigurationSettings.AppSettings["WordMod"];

string documentPath =ConfigurationSettings.AppSettings["WordDoc"];

Response.ContentType ="appliaction/msword";

test.Open(tempaltePath +"Custom_controls.doc");

}

Check below link

Download Files in c#

HC

0 comments:

Post a Comment