程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> asp生成word文件

asp生成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   
                     

                      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"></textarea></p>
<p> </p>
<p>生成Word文檔<input type="button" value="生成" name="B1" onclick="builddoc()"></p>

</form>
</body>

</Html>
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved