vb(1) printer对象使用
2015-04-21 20:59
232 查看
Private Sub Print_网格()
Dim RowPage As Long, ColPage As Long, RowHeight As Double, ColWidth As Double, arrRow() As Long, arrCol() As Long, i As Long, j As Long
Const RowPageHeight As Double = 14571
Const ColPageWidth As Double = 10773
Const HeaderHeight As Double = 1134
RowPage = 0
ReDim arrRow(0) As Long
arrRow(0) = 1
RowHeight = msh.RowHeight(0)
For i = 1 To msh.Rows - 1
RowHeight = RowHeight + msh.RowHeight(i)
If RowPage = 0 Then
If RowHeight > (RowPageHeight - HeaderHeight) Then
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = i
RowHeight = msh.RowHeight(i) + msh.RowHeight(0)
End If
Else
If RowHeight > RowPageHeight Then
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = i
RowHeight = msh.RowHeight(i) + msh.RowHeight(0)
End If
End If
Next i
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = msh.Rows
ColPage = 0
ReDim arrCol(0) As Long
arrCol(0) = 0
ColWidth = 0
For i = 0 To msh.Cols - 1
ColWidth = ColWidth + msh.ColWidth(i)
If ColWidth > ColPageWidth Then
ColPage = ColPage + 1
ReDim Preserve arrCol(UBound(arrCol) + 1) As Long
arrCol(UBound(arrCol)) = i
ColWidth = msh.ColWidth(i)
End If
Next i
ColPage = ColPage + 1
ReDim Preserve arrCol(UBound(arrCol) + 1) As Long
arrCol(UBound(arrCol)) = msh.Cols
For i = 1 To RowPage Step 1
For j = 1 To ColPage Step 1
Call Print_网格分页打印(arrRow(i - 1), arrRow(i) - 1, arrCol(j - 1), arrCol(j) - 1, i, "xxxxxx")
Printer.NewPage
Next j
Next i
Printer.EndDoc
End Sub
Private Sub Print_网格分页打印(ByVal startRow As Long, ByVal endRow As Long, ByVal startCol As Long, ByVal endCol As Long, ByVal PageNum As Long, _
ByVal strTitle As String)
Dim xPos As Double, yPos As Double, i As Long, j As Long
Dim lng表格高度 As Double, lng表格宽度 As Double
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
For i = startCol To endCol Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Print msh.TextMatrix(0, i);
xPos = xPos + msh.ColWidth(j)
Next i
xPos = 567
yPos = yPos + msh.RowHeight(0)
For i = startRow To endRow
Printer.CurrentY = yPos
xPos = 567
For j = startCol To endCol
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Print msh.TextMatrix(i, j);
xPos = xPos + msh.ColWidth(j)
Next j
yPos = yPos + msh.RowHeight(i)
Next i
lng表格高度 = msh.RowHeight(0)
For i = startRow To endRow Step 1
lng表格高度 = lng表格高度 + msh.RowHeight(i)
Next i
lng表格宽度 = 0
For i = startCol To endCol Step 1
lng表格宽度 = lng表格宽度 + msh.ColWidth(i)
Next i
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
xPos = 567
yPos = yPos + msh.RowHeight(0)
For i = startRow To endRow Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
yPos = yPos + msh.RowHeight(i)
If i = endRow Then
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
End If
Next i
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
For i = startCol To endCol Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos, yPos + lng表格高度 - 50)
xPos = xPos + msh.ColWidth(i)
If i = endCol Then
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos, yPos + lng表格高度 - 50)
End If
Next i
Printer.Line (567, 16839.9 - 600)-(11340, 16839.9 - 600)
Printer.CurrentX = 567
Printer.CurrentY = 16839.9 - 500
Printer.Print "第" & PageNum & "页"
End Sub
Dim RowPage As Long, ColPage As Long, RowHeight As Double, ColWidth As Double, arrRow() As Long, arrCol() As Long, i As Long, j As Long
Const RowPageHeight As Double = 14571
Const ColPageWidth As Double = 10773
Const HeaderHeight As Double = 1134
RowPage = 0
ReDim arrRow(0) As Long
arrRow(0) = 1
RowHeight = msh.RowHeight(0)
For i = 1 To msh.Rows - 1
RowHeight = RowHeight + msh.RowHeight(i)
If RowPage = 0 Then
If RowHeight > (RowPageHeight - HeaderHeight) Then
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = i
RowHeight = msh.RowHeight(i) + msh.RowHeight(0)
End If
Else
If RowHeight > RowPageHeight Then
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = i
RowHeight = msh.RowHeight(i) + msh.RowHeight(0)
End If
End If
Next i
RowPage = RowPage + 1
ReDim Preserve arrRow(UBound(arrRow) + 1) As Long
arrRow(UBound(arrRow)) = msh.Rows
ColPage = 0
ReDim arrCol(0) As Long
arrCol(0) = 0
ColWidth = 0
For i = 0 To msh.Cols - 1
ColWidth = ColWidth + msh.ColWidth(i)
If ColWidth > ColPageWidth Then
ColPage = ColPage + 1
ReDim Preserve arrCol(UBound(arrCol) + 1) As Long
arrCol(UBound(arrCol)) = i
ColWidth = msh.ColWidth(i)
End If
Next i
ColPage = ColPage + 1
ReDim Preserve arrCol(UBound(arrCol) + 1) As Long
arrCol(UBound(arrCol)) = msh.Cols
For i = 1 To RowPage Step 1
For j = 1 To ColPage Step 1
Call Print_网格分页打印(arrRow(i - 1), arrRow(i) - 1, arrCol(j - 1), arrCol(j) - 1, i, "xxxxxx")
Printer.NewPage
Next j
Next i
Printer.EndDoc
End Sub
Private Sub Print_网格分页打印(ByVal startRow As Long, ByVal endRow As Long, ByVal startCol As Long, ByVal endCol As Long, ByVal PageNum As Long, _
ByVal strTitle As String)
Dim xPos As Double, yPos As Double, i As Long, j As Long
Dim lng表格高度 As Double, lng表格宽度 As Double
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
For i = startCol To endCol Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Print msh.TextMatrix(0, i);
xPos = xPos + msh.ColWidth(j)
Next i
xPos = 567
yPos = yPos + msh.RowHeight(0)
For i = startRow To endRow
Printer.CurrentY = yPos
xPos = 567
For j = startCol To endCol
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Print msh.TextMatrix(i, j);
xPos = xPos + msh.ColWidth(j)
Next j
yPos = yPos + msh.RowHeight(i)
Next i
lng表格高度 = msh.RowHeight(0)
For i = startRow To endRow Step 1
lng表格高度 = lng表格高度 + msh.RowHeight(i)
Next i
lng表格宽度 = 0
For i = startCol To endCol Step 1
lng表格宽度 = lng表格宽度 + msh.ColWidth(i)
Next i
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
xPos = 567
yPos = yPos + msh.RowHeight(0)
For i = startRow To endRow Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
yPos = yPos + msh.RowHeight(i)
If i = endRow Then
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos + lng表格宽度, yPos - 50)
End If
Next i
xPos = 567
yPos = IIf(PageNum = 1, 2268, 1134)
For i = startCol To endCol Step 1
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos, yPos + lng表格高度 - 50)
xPos = xPos + msh.ColWidth(i)
If i = endCol Then
Printer.CurrentX = xPos
Printer.CurrentY = yPos
Printer.Line (xPos, yPos - 50)-(xPos, yPos + lng表格高度 - 50)
End If
Next i
Printer.Line (567, 16839.9 - 600)-(11340, 16839.9 - 600)
Printer.CurrentX = 567
Printer.CurrentY = 16839.9 - 500
Printer.Print "第" & PageNum & "页"
End Sub
相关文章推荐
- 在VB下使用Printer对象使用心得
- VB中使用ASP对象实例
- VB Printer对象
- VB使用ADO对象连接数据库
- VB中使用ASP对象实例
- VB使用ADO对象链接数据库
- 在VB和Web页面中使用Shell对象
- 【转】介绍vb使用xmlhttp对象、webbrowser控件、inet控件进行Post发包、Get发包的方法
- [2004-8-4]VB.Net学习笔记,使用ADO.Net对象访问数据库,将结果写入ListView
- vb调用excel对象的使用实例:使用excel.application与workbook等并保存工作薄
- VB中ADO控件和ADO对象的使用【链接】
- vb.net GDI+入门——使用Graphics对象绘制线图
- VB.NET中使用SQL Server分布式管理对象(SQL-DMO)
- VB APP对象属性一览表+灵活使用VB的APP对象
- VB 使用WinHttp对象访问证书错误的网站
- WINDOWS SCRIPT HOST对象在VB中的使用
- VB 6.0 使用ADODB对象
- 在VB中使用文件对象
- vb.net GDI+入门——使用Graphics对象填充图形
- [VB.NET源码]78_Command和DataReader对象的使用