报表管理里面设计了3个打印报表模板,有个发货单的窗体,我想设置2个控件,在A控件可以选择不同模板,譬如选择了模板1,点击打印按钮,可以按模板1来打印,应该如何实现这个功能了,麻烦老师指导下下面这个是打印按钮的代码,是固定了模板打印的
Dim Book As New XLS.Book(ProjectPath & "Attachments\BB.xls")
Dim file As String = ProjectPath & "Reports\BB.xls"
Book.Build() '生成细节区
Book.Save(file) '保存工作簿
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(file)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
With Ws.PageSetup
.PaperSize = MSExcel.XlPaperSize.xlPaperA4 '纸张大小
'.CenterHorizontally = True '页面水平居中
'.CenterVertically = True '页面垂直居中
'.Zoom = False '以下设置将缩印在一页内
'.FitToPagesWide = 1 '按照1页的宽度打印
'.FitToPagesTall = 1 '按照1页的高度打印
End With
App.Visible = True
Ws.PrintPreview
App.Visible=False
wb.save
wb.close
App.Quit
[此贴子已经被作者于2019/9/8 20:12:38编辑过]