Dim mb As String = args(0)
Dim tf As String = args(1)
Dim pns As String = args(2)
Dim Book As New XLS.Book(mb) ''模版文件
Book.Build() '生成细节区
Dim fl As String = tf ''临时报表文件
Book.Save(fl) '保存文件
'Dim Proc As New Process '打开工作簿
'Proc.File = fl
'proc.Verb="Print"
'Proc.Start()
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
'App.Visible = True
'Ws.PrintPreview
ws.PrintOut(ActivePrinter:=pns)
App.Quit
------------------------------------
调用代码
ElseIf e.Form.Controls("rbMB").Checked = True '一个模版对应多个记录
For Each s As String In s_mb.Split("|")
'MessageBox.Show("打印模版:" & s )
For Each r As Row In rs
' MessageBox.Show("打印模版:" & s & ",孔号=" & r("孔号") )
' MessageBox.Show(r("孔号"))
Functions.Execute("根据施工记录对应整合查询记录",r)
tn = tn + 1
Functions.Execute("模版打印", Vars("projectMbFiles") & s , ProjectPath & "temp\temp" & tn & ".xls" ,pns )
Next
Next
End If
----------------------------------------