Dec 8

【转】用VBscript生成Word文档 不指定

felix021 @ 2007-12-8 13:04 [IT » 网络] 评论(0) , 引用(0) , 阅读(3673) | Via 本站原创 | |
from  http://hi.baidu.com/ftw118/blog/item/b78d1617acbfdf004a90a7d4.html

用VBscript生成Word文档

代码如下:


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>生成word文档</title>
</head>
<script language="vbscript">
sub builddoc()
     On Error Resume Next

     Dim wApp
    
     Set wApp = CreateObject("Word.Application")
     If Err.number > 0 Then
         Alert "没法保存为Word文件,请正确安装Word97"
     else
     wApp.visible = True
     wApp.Documents.add
    
                      wApp.Selection.TypeParagraph
                      wApp.Selection.Font.Bold = True
                      wApp.Selection.TypeText "19880711"
                    
                      wApp.Selection.ParagraphFormat.Alignment = 1
                       rem 居 中
                                          
                      wApp.Selection.TypeParagraph  
                      wApp.Selection.Font.Bold = false                  
                    
                      wApp.Selection.TypeText "-- http://www.19880711.com"
                        
                      wApp.Selection.TypeParagraph  
                    
                      wApp.Selection.ParagraphFormat.LeftIndent = wApp.CentimetersToPoints(0)
                      wApp.Selection.ParagraphFormat.FirstLineIndent = wApp.CentimetersToPoints(0.72/2*2)
                      
                      wApp.Selection.TypeParagraph
                      wApp.Selection.Font.Bold = false
                      wApp.Selection.ParagraphFormat.Alignment = 0
                    
                      
                      
                          wapp.selection.typetext document.form1.doc1.value
                         wApp.Selection.TypeParagraph  
                    

                       rem 居 右
                      wApp.Selection.TypeParagraph  
                      wApp.Selection.Font.Bold = false                  
                      wApp.Selection.TypeText Now()
                      wApp.Selection.TypeParagraph  
                      wApp.Saved = true
                     wapp.ActiveDocument.SaveAs "c:\a.doc"
                     wapp.close
                    
   end if

end sub
</script>
<body >
<form name="form1" >

<p> </p>
<p><textarea rows="8" name="doc1" cols="46">
</form>
</body>

</html>




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]