Add to Google Add to My Yahoo!

Live Chat Here


Articles on ASP.NET

Tuesday, May 8, 2007

Reading WORD DOCUMENTS FOR ASP.net


using

Word;

using

System.Reflection;

public

partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

DocToHtml(

@"c:\a.doc", @"c:\a.html");

}

void DocToHtml(string docPath, string htmlPath)

{

Application app = new Application ();

app.Visible =

false;

Object o = Missing.Value;

object docFile = docPath;

_Document doc = app.Documents.Open(ref docFile, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);

object fileName = htmlPath;

object format = 8;//Html

doc.SaveAs(

ref fileName, ref format, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);

object t = true;

app.Quit(

ref t, ref o, ref o);

}

}


--
Regards,
Munish Kalra

http://kalraonaspnet.blogspot.com
http://munishmca.co.nr

No comments: