Private Sub Command1_Click()
Printer.ColorMode = 2
Printer.Print " "; ' force a call to StartPage
' Printer.CurrentX = 0 ' restore the position
Printer.ForeColor = vbRed
Printer.Print "page 1nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
' Printer.NewPage
' Printer.Print "Page 2"
Printer.EndDoc
End Sub
Private Sub Command2_Click()
Printer.ColorMode = 2
Printer.Print " "; ' force a call to StartPage
Printer.CurrentX = 0 ' restore the position
Printer.ForeColor = vbRed
Printer.Print "Page 1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Printer.NewPage ' VB only calls EndPage here
' The following three lines are not necessary for NT/Windows 2000
' But you need them if you want to make the code work under Windows 9x or Windows Me
Printer.Print " "; ' force a call to StartPage
Printer.CurrentX = 0 ' restore the position
Printer.ForeColor = vbRed
Printer.Print "Page 2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Printer.EndDoc
End Sub
本文提供两个VBA示例程序,展示如何在打印文档中设置文本颜色,并实现跨页打印。通过调整Printer对象的属性,可以在打印时改变文本颜色,同时确保每段文本在新的一页开始。
2996

被折叠的 条评论
为什么被折叠?



