| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1207 人关注过本帖
标题:VB打印问题
只看楼主 加入收藏
kinger1219
Rank: 2
等 级:论坛游民
帖 子:14
专家分:40
注 册:2019-10-24
结帖率:100%
收藏
 问题点数:0 回复次数:0 
VB打印问题
各位大神请指点,小弟用EXCEL自制的表格做为打印模版.下面是打印代码,第一次加载窗口,可以正常打印.但是第二打印就打印不了.实在是想不出为什么!
我是新手,请各位大神指点.万份感谢!

Private Sub PRI() '打印
On Error Resume Next
Text3.Text = 1
If Adodc2.Recordset.RecordCount = 0 Then Exit Sub
Dim R As String, i As Integer
Dim sSource, sDestination As String
Set mxlApp = New excel.Application
Set mxlApp = CreateObject("Excel.Application")
R = "W:\warehouse\PRI.xlsx"
Set mxlbook = mxlApp.Workbooks.Open(R)
Set mxlSheet = mxlbook.Worksheets(1)
mxlApp.Visible = False
mxlSheet.Cells(2, 2) = Adodc2.Recordset.Fields("LLDW") '领料单位
mxlSheet.Cells(2, 4) = Adodc2.Recordset.Fields("LLData")  '日期
mxlSheet.Cells(2, 7) = Adodc2.Recordset.Fields("QXDH")  '销售单号
mxlSheet.Cells(1, 7) = Adodc2.Recordset.Fields("LLDH") '领料单号
'mxlSheet.Cells(1, 2) = Adodc2.Recordset.Fields("LLDH") '款号
mxlSheet.Cells(13, 5) = Adodc2.Recordset.Fields("LLKDR") '开单人
Adodc2.Recordset.MoveFirst
For H = 4 To Adodc2.Recordset.RecordCount + 5
mxlSheet.Cells(H, 1) = Adodc2.Recordset.Fields("wlnumber") '物料编码
mxlSheet.Cells(H, 2) = Adodc2.Recordset.Fields("wlname")    '规格名称
mxlSheet.Cells(H, 3) = Adodc2.Recordset.Fields("wlunit")      '单位
mxlSheet.Cells(H, 4) = Adodc2.Recordset.Fields("LLSL") '领料数量'
 mxlSheet.Cells(H, 5) = Adodc2.Recordset.Fields("wlprice") '单价
mxlSheet.Cells(H, 7) = Adodc2.Recordset.Fields("wlremarks") '备注
Adodc2.Recordset.MoveNext
Next H
Text3.Text = ""
    ActiveWindow.SelectedSheets.PrintOut Copies:=1 '直接使用默认打印机打印
mxlApp.DisplayAlerts = False  '设置关闭EXCEL时不提示是否保存'
mxlbook.Application.Quit '关闭EXCEL
End Sub
搜索更多相关主题的帖子: Set Fields excel Recordset 打印 
2020-03-03 11:02
快速回复:VB打印问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020816 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved