以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]紧急:如何批量打印直接打印word报表,不预览  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=74358)

--  作者:ehomecd
--  发布时间:2015/9/9 12:36:00
--  [求助]紧急:如何批量打印直接打印word报表,不预览
紧急:如何批量打印直接打印word报表,不预览;按照选择的行,批量直接打印word报表

Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
With Tables("员工资料")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        For i As Integer = .TopPosition To .BottomPosition
            Dim r As Row = .Rows(i)
            Dim fileName As String = ProjectPath & "Reports\\"& r("姓名") &".doc" \'指定目标文件
            Dim wrt As New WordReport(Tables("员工资料"),tm,fileName) \'定义一个WordReport
            wrt.BuildOne(r)
            Dim app As New MSWord.Application
            try
                app.Documents.Open(fileName)
                \'app.Documents(fileName).PrintPreview
                \'app.Visible = True
                app.Documents(fileName).PrintOut \'打印
            catch ex As exception
                msgbox(ex.message)
            finally
                app.Quit
            End try
        Next
    End If
End With
[此贴子已经被作者于2015/9/9 13:18:48编辑过]

--  作者:大红袍
--  发布时间:2015/9/9 14:10:00
--  
Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
With Tables("员工资料")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        For i As Integer = .TopPosition To .BottomPosition
            Dim r As Row = .Rows(i)
            Dim fileName As String = ProjectPath & "Reports\\"& r("姓名") &".doc" \'指定目标文件
            Dim wrt As New WordReport(Tables("员工资料"),tm,fileName) \'定义一个WordReport
            wrt.BuildOne(r)
            wrt.Print
            wrt.quit
        Next
    End If
End With

--  作者:ehomecd
--  发布时间:2015/9/9 16:56:00
--  
非常感谢,还有一个问题,上边代码如何改动,让批量导出word报表,而不用预览也不用打印?
--  作者:大红袍
--  发布时间:2015/9/9 17:54:00
--  

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=74379&skin=0

 

 


--  作者:machle
--  发布时间:2015/10/18 9:24:00
--  回复:(大红袍)Dim tm As String  = ProjectPa...
我用这段代码,该怎么选定表里的数据呢?

我现在有2000多条数据,每条数据100个字段,用这段代码得不到数据。不知道怎么回事。

--  作者:大红袍
--  发布时间:2015/10/18 10:27:00
--  

回复5楼,4楼的代码要执行,先选中要打印的数据。

 

如果全部打印这样写

 

Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
For Each r As DataRow In DataTables("员工资料").Select("")
    Dim fileName As String = ProjectPath & "Reports\\"& r("姓名") &".doc" \'指定目标文件
    Dim wrt As New WordReport(Tables("员工资料"),tm,fileName) \'定义一个WordReport
    wrt.BuildOne(r)
    wrt.Print
    wrt.quit
Next