Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 9821|回复: 6

[已解决]打印模板中导入数据进行批量打印

[复制链接]
发表于 2013-4-29 13:37 | 显示全部楼层 |阅读模式
    批量打印编辑;按条件查找sheet1数据表内容到LISTVIEW里,然后将LISTVIEW的数据按照打印模板进行批量打印,模板打印数据信息每页限15条。
    老师帮忙给编辑一下,

      真是不好意思,在五一劳动节之际还在麻烦老师。

      非常感谢老师的每次回复于帮助。
最佳答案
2013-4-30 08:07
打印按钮的代码。
另外,你的序号了漏了个数。
  1. Private Sub CommandButton2_Click()    '清空
  2.     Dim arrPrint(1 To 15, 1 To 9)
  3.     Dim i As Long, k As Long, l As Long

  4.     Dim arrPos
  5.     arrPos = Array(0, 1, 2, 4, 6, 7, 8)
  6.     With Me.ListView1
  7.         If .ListItems.Count = 0 Then
  8.             MsgBox "列表中无数据可打印"
  9.             Exit Sub
  10.         End If
  11.         Application.ScreenUpdating = False
  12.         'Application.DisplayAlerts = False
  13.         
  14.         For i = 1 To .ListItems.Count
  15.             l = l + 1
  16.             For k = 1 To 6
  17.                 arrPrint(l, arrPos(k)) = .ListItems(i).SubItems(k)
  18.             Next
  19.             If l = 15 Then
  20.                 With Worksheets("打印模板")
  21.                     .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  22.                     .PrintOut
  23.                     .Range("c5:k19").ClearContents
  24.                     Erase arrPrint
  25.                 End With
  26.                 l = 0
  27.             End If
  28.         Next
  29.         If l > 0 Then
  30.             With Worksheets("打印模板")
  31.                 .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  32.                 .PrintOut
  33.                 .Range("c5:k15").ClearContents
  34.             End With
  35.         End If
  36.     End With
  37.     Application.ScreenUpdating = True
  38.     'Application.DisplayAlerts = true
  39.     MsgBox "打印完成"
  40. End Sub
复制代码

入库批量返品情况总结.rar

57.12 KB, 下载次数: 291

发表于 2013-4-30 08:07 | 显示全部楼层    本楼为最佳答案   
打印按钮的代码。
另外,你的序号了漏了个数。
  1. Private Sub CommandButton2_Click()    '清空
  2.     Dim arrPrint(1 To 15, 1 To 9)
  3.     Dim i As Long, k As Long, l As Long

  4.     Dim arrPos
  5.     arrPos = Array(0, 1, 2, 4, 6, 7, 8)
  6.     With Me.ListView1
  7.         If .ListItems.Count = 0 Then
  8.             MsgBox "列表中无数据可打印"
  9.             Exit Sub
  10.         End If
  11.         Application.ScreenUpdating = False
  12.         'Application.DisplayAlerts = False
  13.         
  14.         For i = 1 To .ListItems.Count
  15.             l = l + 1
  16.             For k = 1 To 6
  17.                 arrPrint(l, arrPos(k)) = .ListItems(i).SubItems(k)
  18.             Next
  19.             If l = 15 Then
  20.                 With Worksheets("打印模板")
  21.                     .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  22.                     .PrintOut
  23.                     .Range("c5:k19").ClearContents
  24.                     Erase arrPrint
  25.                 End With
  26.                 l = 0
  27.             End If
  28.         Next
  29.         If l > 0 Then
  30.             With Worksheets("打印模板")
  31.                 .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  32.                 .PrintOut
  33.                 .Range("c5:k15").ClearContents
  34.             End With
  35.         End If
  36.     End With
  37.     Application.ScreenUpdating = True
  38.     'Application.DisplayAlerts = true
  39.     MsgBox "打印完成"
  40. End Sub
复制代码
回复

使用道具 举报

发表于 2013-4-30 08:09 | 显示全部楼层
  1. Private Sub CommandButton2_Click()    '清空
  2.     Dim arrPrint(1 To 15, 1 To 9)
  3.     Dim i As Long, k As Byte, l As Byte

  4.     Dim arrPos
  5.     arrPos = Array(0, 1, 2, 4, 6, 7, 8)
  6.     With Me.ListView1
  7.         If .ListItems.Count = 0 Then
  8.             MsgBox "列表中无数据可打印"
  9.             Exit Sub
  10.         End If
  11.         Application.ScreenUpdating = False
  12.         'Application.DisplayAlerts = False
  13.         
  14.         For i = 1 To .ListItems.Count
  15.             l = l + 1
  16.             For k = 1 To 6
  17.                 arrPrint(l, arrPos(k)) = .ListItems(i).SubItems(k)
  18.             Next
  19.             If l = 15 Then
  20.                 With Worksheets("打印模板")
  21.                     .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  22.                     .PrintOut
  23.                     .Range("c5:k19").ClearContents
  24.                     Erase arrPrint
  25.                 End With
  26.                 l = 0
  27.             End If
  28.         Next
  29.         If l > 0 Then
  30.             With Worksheets("打印模板")
  31.                 .Range("c5").Resize(l, UBound(arrPrint, 2)) = arrPrint
  32.                 .PrintOut
  33.                 .Range("c5:k15").ClearContents
  34.             End With
  35.         End If
  36.     End With
  37.     Application.ScreenUpdating = True
  38.     'Application.DisplayAlerts = true
  39.     MsgBox "打印完成"
  40. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2013-5-2 16:26 | 显示全部楼层
老师,像我附件类型内容能够封装吗?如果想封装应该做些什么?
回复

使用道具 举报

 楼主| 发表于 2013-5-2 16:43 | 显示全部楼层
有一个网站   http://www.onlyit.cn/soft_edt
新用户这里下载库存管理系统软件(6M左右)挺好,我想仿照这个做,可是不知道怎么编辑的,
回复

使用道具 举报

发表于 2013-12-16 23:58 | 显示全部楼层
qihaizhong2013 发表于 2013-5-2 16:43
有一个网站   http://www.onlyit.cn/soft_edt
新用户这里下载库存管理系统软件(6M左右)挺好,我想仿照这 ...

很好的绿色、免费软件,值得支持、收藏,谢谢
回复

使用道具 举报

发表于 2015-10-20 16:21 | 显示全部楼层
支持下,与更多朋友分享,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-20 23:20 , Processed in 0.834054 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表