回 帖 发 新 帖 刷新版面

主题:[转帖]asp生成word文档

<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>

回复列表 (共7个回复)

沙发

你好,我想问一下这程序具体完成什么功能?
怎么ASP生成WORD?

板凳

运行的结果是:将页面上文本区域中的内容写到c:\a.doc的word文件中去了。

3 楼

好东西怎么就没人顶?顶一下,让更多的人看到!

4 楼

到编程先锋论坛上去看看吧!
http://www.bcxf.cn

5 楼

[quote]运行的结果是:将页面上文本区域中的内容写到c:\a.doc的word文件中去了。[/quote]

个人认为:若要将页面上文本区域的内容写到WORD文档中,只要用FSO生成一个后缀为DOC的文件,然后将内容写入就可以了,没必要这么麻烦,因为现在MS的OFFICE对各种格式的文本都可以进行转换。

以上代表个人意见,讲得不对敬请指出!

6 楼

[quote][quote]运行的结果是:将页面上文本区域中的内容写到c:\a.doc的word文件中去了。[/quote]

个人认为:若要将页面上文本区域的内容写到WORD文档中,只要用FSO生成一个后缀为DOC的文件,然后将内容写入就可以了,没必要这么麻烦,因为现在MS的OFFICE对各种格式的文本都可以进行转换。

以上代表个人意见,讲得不对敬请指出![/quote]

那要是想对文本进行格式化呢?

7 楼

这叫VBScript~与ASP无关。

我来回复

您尚未登录,请登录后再回复。点此登录或注册