Results 1 to 9 of 9

Thread: [RESOLVED] Add Text to PrintForm

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  3. #3

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    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

  4. #4
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    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
    Rob C

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Add Text to PrintForm

    Try
    vb Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    2. ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    3.  
    4. Private Const VK_MENU As Byte = &H12
    5. Private Const VK_SNAPSHOT As Byte = &H2C
    6. Private Const KEYEVENTF_KEYUP = &H2
    7.  
    8. Private Sub cmdPrintForm_Click()
    9. Dim lWidth As Long, lHeight As Long
    10.     Clipboard.Clear
    11.     Call keybd_event(VK_MENU, 0, 0, 0)
    12.     Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
    13.     DoEvents
    14.     Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)
    15.     Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
    16.     Printer.Print
    17.     If Width > Printer.ScaleWidth Then
    18.         lWidth = Printer.ScaleWidth
    19.         lHeight = (Printer.ScaleWidth / Width) * Height
    20.     Else
    21.         lWidth = Width
    22.         lHeight = Height
    23.     End If
    24.     Printer.PaintPicture Clipboard.GetData, 0, 0, lWidth, lHeight
    25.     Printer.EndDoc
    26. End Sub

  6. #6

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Re: Add Text to PrintForm

    Quality!
    That what I was looking for.

  7. #7
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    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.
    Rob C

  8. #8

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    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.

  9. #9
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: [RESOLVED] Add Text to PrintForm

    Thanks, I will give CutePDF a trial
    Rob C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width