我现在用DATE REPORT无法解决的难点:1 每张凭证的行数不同2 打印纸张的大小控制
解决方案 »
- WINSOCK程序网络通信
- 请教datagrid控件如何控制显示格式?
- 为什么总是提示“HSHFLEXGRID不支持所绑定的数据类型”
- 高手帮我看看!!!
- 关于ADO和98系统,在线等!
- 提请斑竹、老猫彻底封杀以下账号 easthotvb bardon2002 即相关恶作剧贴,证贴据如下。
- 生成CODE 39和CODE 128条形码
- 论人的复杂性与动物的简易性(不知是荒诞还是写实)
- 急急。。。一个关于局域网winsock问题,大侠请进,请帮忙!!!
- 当ListView允许多选时,怎样才能得到所选Item的Text
- 用vb的data控件,执行语句:data1.recordest.updata时,出错:该操作被关联对象取消。怎么回事??
- 哪位想在寒假里学会 CPU 卡编程的,进来看看。
设置Printer的width和height,决定自定义纸张的大小
设置Printer的CurrentX、CurrentY,在指定的位置输出字符
Dim PX, PY As Single'偏移量
dim sName as String
Printer.ScaleMode = vbMillimeters '设置打印单位为毫米
Printer.FontName = "宋体" '打印字体
Printer.FontSize = 13 '打印字号
Printer.PaperSize = vbPRPSA4 '打印纸张为A4纸rinter.CurrentX = 26 + PX '打印姓名
Printer.CurrentY = 45 + (7 - 4.6) / 2 + PY
Printer.Print sNamePrinter.EndDoc
Dim i, j As Integer
Dim strdep As String '部门名称
Dim strName As String '人员名称
Dim strDate As String '日期
Dim envHei As Integer '信封高度
Dim preRow As Integer '当前行
Const myheight = 1000 '固定高度
Const mywidth = 1000 '固定宽度
Const mytop1 = 1550 '最顶端高度 1550 1650
Const mytop2 = 12670 '第二个最顶端高度 12670 12670
Const mxtop = 1980 '明细高度 1800 1800
Const mxtop2 = 12970 '第二个明晰高度 12970 12970
Const sep = 300 '行间距
Dim depX, depY, depwidth, depheight As Integer '部门宽度
Dim nameX, nameY, namewidth, nameheight As Integer '姓名宽度
Dim dateX, dateY, datewidth, dateheight As Integer '日期宽度
Dim left(5) As Integer '各列的x
Dim myPages As Integer ' 页数
On Error Resume Next
If Grid1.Rows < 2 Then
MsgBox "没有任何记录!", vbInformation + vbOKOnly, "提示"
Exit Sub
End If
strdep = Grid1.TextMatrix(myPages + 1, Grid1.Cols - 1) '部门名称
strName = Grid1.TextMatrix(myPages + 1, 7) '临时人员姓名 需要改动
strDate = Grid1.TextMatrix(myPages + 1, 6)
envheight = 5225 'tips
envHei = 6200 '设定信封高度
preRow = 0 '当前行为第0行
depX = 700: depY = 2300: depwidth = 2000: depheight = 1000
nameX = 700: nameY = 2950: namewidth = 2000: nameheight = 1000
dateX = 700: dateY = 3600: datewidth = 2000: dateheight = 1000
For i = 0 To 5
left(i) = 3500 + 1150 * i
Next i
frm_print.vp.StartDoc
With frm_print.vp
For myPages = Val(txtPage1.Text) To Val(txtPage2.Text) Step 2
For j = 0 To 1
strdep = Grid1.TextMatrix(myPages + j, Grid1.Cols - 1) '部门名称
strName = Grid1.TextMatrix(myPages + j, 7) '临时人员姓名 需要改动
strDate = Grid1.TextMatrix(myPages + j, 6)
.FontSize = 16
.FontBold = True
.FontName = "隶书"
.TextBox strdep, depX, depY + j * envheight, depwidth, depheight '部门名称
.FontSize = 22
.FontBold = False
.FontName = "华文行楷"
.TextBox strName, nameX, nameY + j * envheight, namewidth, nameheight '员工姓名
.FontSize = 12
.FontBold = False
.FontName = "隶书"
.TextBox strDate, dateX, dateY + j * envheight, datewidth, dateheight '日期
.FontSize = 10
.FontBold = True
.FontName = "黑体"
.TextBox "项目", left(0), mytop1 + j * envheight, mywidth, myheight '项目1列
.TextBox "金额", left(1) + 200, mytop1 + j * envheight, mywidth, myheight '金额1列
.TextBox "项目", left(2), mytop1 + j * envheight, mywidth, myheight '项目2列
.TextBox "金额", left(3) + 200, mytop1 + j * envheight, mywidth, myheight '金额2列
.TextBox "项目", left(4), mytop1 + j * envheight, mywidth, myheight '项目3列
.TextBox "金额", left(5), mytop1 + j * envheight, mywidth, myheight '金额3列
'明细(1列)
.FontBold = False
.FontName = "宋体"
For mxcol = 8 To Grid1.Cols - 1
If mxcol - 8 > 7 Then
premxcol = mxcol
Exit For
End If
' .TextAlign = taLeftMiddle
.TextBox Grid1.TextMatrix(0, mxcol), left(0), mxtop + (mxcol - 8) * sep + j * envheight, mywidth, myheight
' .TextAlign = taRightMiddle
.TextBox Grid1.TextMatrix(myPages + j, mxcol), left(1) + 200, mxtop + (mxcol - 8) * sep + j * envheight, mywidth, myheight
Next mxcol '明细(2列)
For mxcol = premxcol To Grid1.Cols - 2
If mxcol - 8 > 15 Then
premxcol = mxcol
Exit For
End If
' .TextAlign = taLeftMiddle
.TextBox Grid1.TextMatrix(0, mxcol), left(2), mxtop + (mxcol - 16) * sep + j * envheight, mywidth, myheight
' .TextAlign = taRightMiddle
.TextBox Grid1.TextMatrix(myPages + j, mxcol), left(3) + 200, mxtop + (mxcol - 16) * sep + j * envheight, mywidth, myheight
Next mxcol
'明细(3列) For mxcol = premxcol To Grid1.Cols - 2
If mxcol - 8 > 23 Then
premxcol = mxcol
Exit For
End If
' .TextAlign = taLeftMiddle
.TextBox Grid1.TextMatrix(0, mxcol), left(4), mxtop + (mxcol - 24) * sep + j * envheight, mywidth, myheight
' .TextAlign = taRightMiddle
.TextBox Grid1.TextMatrix(myPages + j, mxcol), left(5), mxtop + (mxcol - 24) * sep + j * envheight, mywidth, myheight
Next mxcol
.DefaultDevice = True
.PageHeight = 850
If myPages >= frm_main.Grid1.Rows - 1 Then
frm_print.vp.EndDoc
frm_print.Show 1
Exit Sub
End If
Next j
.NewPage
Next myPages
End With
frm_print.vp.EndDoc
frm_print.Show 1