Javascript implementation:
<MCE: Script Type = "text/JavaScript"> <! -- <Br/> function readword () <br/>{< br/> var div1 = document. getelementbyid ("div1"); <br/> var wordapp, worddoc, STR; <br/> wordapp = new activexobject ("word. application "); <br/> worddoc = wordapp. documents. open ("F: // work day .doc"); <br/> STR = worddoc. content. text; <br/> worddoc. close (); <br/> wordapp. quit (); <br/> div1.innerhtml = STR; <br/>}</P> <p> // --> </MCE: SCRIPT>
<Div id = "div1"> <br/> </div> <br/> <input id = "button2" type = "button" value = "button" onclick =" readword (); "/>
C # implementation: (Add office Reference)
<Asp: literal id = "literal1" runat = "server"> </ASP: literal>
Protected void page_load (Object sender, eventargs e) <br/>{< br/> This. literal1. TEXT = gettest ("F: // work log .doc"); <br/>}< br/> Public String gettest (string filename) <br/>{< br/> Microsoft. office. interOP. word. applicationclass wordapi = new Microsoft. office. interOP. word. applicationclass (); <br/> Object fileobject = filename; <br/> Object nullobj = system. reflection. missing. value; <br/> Microsoft. office. interOP. word. document Doc = wordapi. documents. open (ref fileobject, ref nullobj, ref nullobj, <br/> ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); <br/> string strtext = Doc. content. text; <br/> Doc. close (ref nullobj, ref nullobj, ref nullobj); <br/> wordapi. quit (ref nullobj, ref nullobj, ref nullobj); </P> <p> return strtext; <br/>}