-
Dec 9th, 2012, 07:46 AM
#1
Thread Starter
Hyperactive Member
Background color in Printer object.
Hi,
Is there a way to print white letters on a black background using the Printer object?
-
Dec 9th, 2012, 08:29 AM
#2
Re: Background color in Printer object.
Think of the Printer page as a Form or PictureBox. It has most of the
same methods/properties, except the Printer object doesn't have a BackColor.
The code below prints the text on a form, but you can do the same
with the Printer object.
Code:
Dim Txt As String
Dim PosX As Single
Dim PosY As Single
Txt = "Hello From VB"
PosX = 150
PosY = 150
Line (PosX, PosY)-(PosX + TextWidth(Txt), PosY + TextHeight(Txt)), vbBlack, BF 'Printer.Line
CurrentX = PosX 'Printer.CurrentX
CurrentY = PosY 'Printer.CurrentY
ForeColor = vbWhite 'Printer.ForeColor
Print Txt 'Printer.Print
Last edited by si_the_geek; Dec 11th, 2012 at 03:23 AM.
Reason: fixed typo in code tags
-
Dec 9th, 2012, 09:47 AM
#3
Thread Starter
Hyperactive Member
Re: Background color in Printer object.
Thank you VBClassicRocks
Your code works. Thank you very much.
Last edited by svg3414; Dec 9th, 2012 at 10:12 AM.
-
Dec 9th, 2012, 10:01 AM
#4
Re: Background color in Printer object.
See if this does it.
Code:
Private Sub cmdPrint_Click()
' Use the line method to set the background color of the page
Printer.Line (0, 0)-(Printer.Width, Printer.Height), vbBlack, BF
' Set the print color on the page
Printer.ForeColor = vbWhite
' Set the print location
Printer.CurrentX = 1440
Printer.CurrentY = 1440
' Send some text to the printer
Printer.Print "White text on black background"
' Release the document to the printer
Printer.EndDoc
End Sub
-
Dec 9th, 2012, 10:14 AM
#5
Thread Starter
Hyperactive Member
Re: Background color in Printer object.
Originally Posted by MarkT
See if this does it.
Code:
Private Sub cmdPrint_Click()
' Use the line method to set the background color of the page
Printer.Line (0, 0)-(Printer.Width, Printer.Height), vbBlack, BF
' Set the print color on the page
Printer.ForeColor = vbWhite
' Set the print location
Printer.CurrentX = 1440
Printer.CurrentY = 1440
' Send some text to the printer
Printer.Print "White text on black background"
' Release the document to the printer
Printer.EndDoc
End Sub
Actually the earlier code works. I had missed out a line while copying and pasting.
Sorry for troubling you.
-
Dec 9th, 2012, 10:15 AM
#6
Thread Starter
Hyperactive Member
Re: Background color in Printer object.
Originally Posted by MarkT
See if this does it.
Code:
Private Sub cmdPrint_Click()
' Use the line method to set the background color of the page
Printer.Line (0, 0)-(Printer.Width, Printer.Height), vbBlack, BF
' Set the print color on the page
Printer.ForeColor = vbWhite
' Set the print location
Printer.CurrentX = 1440
Printer.CurrentY = 1440
' Send some text to the printer
Printer.Print "White text on black background"
' Release the document to the printer
Printer.EndDoc
End Sub
Actually the earlier code works. I had missed out a line while copying and pasting.
Sorry for troubling you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|