asp中将内容生成word文档的函数

2009-05-12 15:08:10来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

日常工作中经常需要把很多内容直接转换成word文档,于是写了个生成word文档的asp函数,代码如下:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<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 "programfan"
                     wApp.Selection.ParagraphFormat.Alignment = 1
                      rem 居 中  

                     wApp.Selection.TypeParagraph  
                     wApp.Selection.Font.Bold = false                  
                     wApp.Selection.TypeText "-- programfan.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   

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:ASP按照字数限制自动截取标题内容

下一篇:用ASP自动清空IE缓存里的内容