发新话题
打印

怎样调用word?

怎样调用word?

我有一页面,里面有一部分文字是静态写上的,又一部分是读数据库读出来的。  
现在我想把页面的文字打印出来,想调用word进行排版,怎样调用。  
除了Ctrl  C  和Ctrl  V,  还有什么办法吗?  
请各位高手帮忙!

TOP

<HTML>   
<HTML  XMLNS:IE>  
<title>将浏览器文本导入到word</title>  

   

<SCRIPT>  
       function  onDownloadDone(s)  {   
               content.value=s;  
       }  
</SCRIPT>  
<textarea  name="content"  cols=30  rows=20>  
点击Text2Word,可以把这里的数据转成为Word.  

也可先导入文本件.  
点击浏览选择文本文件.  
再点击Text2Word,把文本文件的数据转成为Word.  
</textarea>  
<IEownload  ID="oDownload"  STYLE="behavior:url(#default#download)"  />  
<input  type=file  name='p'  onchange="oDownload.startDownload(p.value,   
onDownloadDone)"  size="20">  
<input  type="button"  onclick="Text2Word(document.all.content.value)"   
value="Text2Word">  
<input  type="button"  onclick="Text2Word(document.documentElement.innerHTML)"   
value="导出该页源代码到Word">  
<script>   
function  Text2Word(str)  
{  
       var  wrd=new  ActiveXObject("Word.Application")   
       wrd.visible=true   
       wrd.Documents.Open("c:\\word.doc")   
       wrd.Selection.TypeText(str)   
       wrd.Application.Activate()   
       wrd.ActiveDocument.SaveAs("c:\\word2.doc")  
       //wrd.quit();  
       wrd=null   
}  
   
</script>   

   
</HTML>

TOP

Dim  objWD  objDOC  
set  objWD=creatobject("word.application")  
         objWD.visible=true  
      
         objWD.document.add  
set  objDOC=objWD.activeDocument  
         objDOC.typetext="word"  
         objDOC.saveas  "word.doc"  
   
         objWD.quit  
set  objDOC=nothing  
set  objWD=nothing

TOP

发新话题