|
-
Apr 30th, 2007, 10:52 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Add Text to PrintForm
I am currently printing my form with Me.PrintForm.
Is there anyway to add some text to the bottom of the image that is printed.
I tried the following but it doesn't get the form image
Code:
'Print picture at certain location
Printer.PaintPicture Me.Image, 20, 20
Printer.CurrentX = 10 'Print text at certain location
Printer.CurrentY = 100
Printer.Print "User Name: " & Me.lblUser.Caption
'Tell it to print
Printer.EndDoc
-
Apr 30th, 2007, 11:05 AM
#2
Re: Add Text to PrintForm
Put a label on the bottom of the form with its visible property set to False.
Toggle it to true before the Me.Print form and back to False after the Printer.EndDoc
-
May 3rd, 2007, 05:31 AM
#3
Thread Starter
Frenzied Member
Re: Add Text to PrintForm
Me.PrintForm does print out the image of the form, but I can't put lots of text beneath it.
Thats why I am trying Printer.PaintPicture Me.Image in combination with Printer.Print "User Name: blah blah blah"
However, this just prints out a grey box the size of the form (with text underneath).
i.e. none of the controls on the form are printed out
-
May 3rd, 2007, 07:37 AM
#4
Fanatic Member
Re: Add Text to PrintForm
Rod Stephens has an example in his VB Graphics Programming 2nd Edition book, called HiRes
It works like VB's PrintForm, except it uses code to read what is on the form, and sends it to the printer. You get a high resolution print instead of the PrintForm's fuzzy one. (You get a Preview as well)
Rod has a very extensive site, but he has never made his HiRes available on that site.
However, there is one very small example on his site, which illustrates the concept.
http://vb-helper.com/howto_print_labels_textboxes.html
If you go down this path, I assume that you have available space that you can print text (since paper is longer than the screen).
Since the example is using VB's Print commands, it should be easy to also send the extra text that you desire
I am 99 % sure that you could do that with Rod's approach.
However you would have to expand the simple example on Rod's site, or buy a copy of his book.
I am sure that if you attempted to develop the simple example further, there would be those (in this forum), that could assist
-
May 3rd, 2007, 07:39 AM
#5
Re: Add Text to PrintForm
Try
vb Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_MENU As Byte = &H12
Private Const VK_SNAPSHOT As Byte = &H2C
Private Const KEYEVENTF_KEYUP = &H2
Private Sub cmdPrintForm_Click()
Dim lWidth As Long, lHeight As Long
Clipboard.Clear
Call keybd_event(VK_MENU, 0, 0, 0)
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)
Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
Printer.Print
If Width > Printer.ScaleWidth Then
lWidth = Printer.ScaleWidth
lHeight = (Printer.ScaleWidth / Width) * Height
Else
lWidth = Width
lHeight = Height
End If
Printer.PaintPicture Clipboard.GetData, 0, 0, lWidth, lHeight
Printer.EndDoc
End Sub
-
May 3rd, 2007, 08:05 AM
#6
Thread Starter
Frenzied Member
Re: Add Text to PrintForm
Quality!
That what I was looking for.
-
May 3rd, 2007, 08:12 AM
#7
Fanatic Member
Re: [RESOLVED] Add Text to PrintForm
I am guessing he means you Hack ?
It does look pretty cool.
If my ink cartridges would stop freezing from lack of use, I would be giving it a try myself.
-
May 3rd, 2007, 08:14 AM
#8
Thread Starter
Frenzied Member
Re: [RESOLVED] Add Text to PrintForm
Rob: Install a free PDF printer such as CutePDF or PDF995
then you can try it out to your hearts desire without wasting paper or ink.
-
May 3rd, 2007, 09:04 AM
#9
Fanatic Member
Re: [RESOLVED] Add Text to PrintForm
Thanks, I will give CutePDF a trial
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
|