) ’打印页脚码
printer.NewPage ’next page
dd = prnt1(4000, 700, 18, ss$) ’打印标题
strx = strx1
stry = stry1
printer.Line (strx - 50, stry - 30)-(strx +
kan - 10, stry - 30) ’打印第一行
Else
stry = stry + linw
End If Next
st = stry
If p < page1 Then ’在最后页剩余划空行
For o = p To page1 + 1
strx = strx1
printer.Line (strx - 50, stry - 30)-(strx +
kan - 10, stry - 30)
stry = stry + linw
Next
End If
stry = stry1
strx = strx1
stry = stry1’line col
For n = 0 To 8
printer.Line (strx - 30, stry - 30)-(strx -
30, stry + (page1 + 2) * linw)
strx = strx + a(n)
Next
printer.Line (strx - 30, stry - 30)-(strx -
30, stry + (page1 + 2) * linw)
pp=pp+1
foot$="第 "+cstr(pp)+" 页"
dd = prnt1(strx - 30-1000, stry + (page1 +
2) * linw+100, 10, foot$) ’打印页脚码
printer.EndDoc ’打印结束
End sub
这种方法通过灵活的编程可以方便地调整字体、字型、线形、页 面、纸张大小等,可打印出比较满意的效果。
如果
计算机上装有Microsoft Word和Microsoft Excel,则可把GR ID的表格通过VB发送到这些应用
程序中去,生成Microsoft Word和Mic rosoft Excel表格。这样可以充分利用它们的打印、编辑功能,打印 出更理想的效果。下面逐一介绍。
方法三:通过生成Word表格打印
1. 在declaration 中写入:
Dim msword As Object
2. 加入打印命令按钮(command2),CAPTION设为"生成Word表格", 写入下面代码:Pri vate Sub command2_Click()
screen.MousePointer = 11
Set msword = CreateObject("word.basic")
Dim AppID, ReturnValue
appID = Shell("d:\office97\office\WIN-
WORD.EXE", 1) ’运行Word
msword.AppActivate "Microsoft Word"
full
Screen.MousePointer = 0 End Sub
3. 写入以下过程full() Sub full()
Dim i As Integer, j As Integer, col As Integer,
row As Integer
Dim cellcontent As String
Me.Hide
cols = 4 ’表格的列数
row = gridrow ’打印表的行数
msword.filenewdefault
msword.MsgBox "正在建立MS_WORD报表,请稍候
……", "", -1
msword.leftpara
msword.screenupdating 0
msword.tableinserttable , col, row, , , 16, 167
msword.startofdocument
for j=0 to gridrow ’表格的行数
grid1.row=j
For i = 1 To cols
Gri1d.col=i
If IsNull(grid1.text) Then
cellcontent$ = ""
Else
cellcontent$ = grid1.text
End If
msword.Insert cellcontent$
msword.nextcell
Next i
Next j
msword.tabledeleterow
msword.startofdocument
msword.tableselectrow
msword.tableheadings 1
msword.centerpara
’msword.startdocument
msword.screenrefresh
msword.screenupdating 1
msword.MsgBox "结束", "", -1
Me.Show End Sub
方法四:通过发送到Excel实现表格打印
1. 加入打印命令按钮(command3),CAPTION设为"生成EXCEL表格" ,写入下面代码: Private Sub command3_Click()
Dim i As Integer
Dim j As In