How to print the contents in a form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunbalait
    New Member
    • Feb 2007
    • 164

    How to print the contents in a form?

    In my form I have few label and text boxes and a pi'cture box. What i want is to print the entire form contents including the image. Printform method not working correctly.

    If I used that method it prints the contents within a limited portion in the A4 size paper.. Even if the contents are less I want to get the printout in the Wholw paper
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by arunbalait
    In my form I have few label and text boxes and a pi'cture box. What i want is to print the entire form contents including the image. Printform method not working correctly.

    If I used that method it prints the contents within a limited portion in the A4 size paper.. Even if the contents are less I want to get the printout in the Wholw paper

    i'm not getting why you are printing it to form? You can directly print it to paper.

    Comment

    • arunbalait
      New Member
      • Feb 2007
      • 164

      #3
      Sorry sorry to paper via printer... Ok now?

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Originally posted by arunbalait
        Sorry sorry to paper via printer... Ok now?
        i think this page will help you

        http://www.thescripts. com/forum/thread586885.ht ml

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by hariharanmca
          i think this page will help you ...
          I doubt that thread will help much - it basically ends up by saying "use PrintForm", and in this case we have been told it doesn't work.

          I think we really need to clarify exactly what is being asked here, as the original post was a bit cryptic.

          Please correct me if I'm wrong here, but as far as I can see you are actually asking the following two questions:
          1. PrintForm is not printing the image which is in a picturebox on the form - how to fix?
          2. The printout is too small - how do I expand it to the whole page?
          Does this sound right?

          Comment

          • arunbalait
            New Member
            • Feb 2007
            • 164

            #6
            There are four label boxes at the top left corner and four label boxes at the top right corner of my form. And then nearer to the center of the form a picture box and at the bottom a command button to print. BY using PrintForm method if i take printout in a A4 sheet the whole form printed within Half of the page. So I want to format it to print in the entire paper as a neat format. Got it?

            Thanx

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by arunbalait
              There are four label boxes at the top left corner and four label boxes at the top right corner of my form. And then nearer to the center of the form a picture box and at the bottom a command button to print. BY using PrintForm method if i take printout in a A4 sheet the whole form printed within Half of the page. So I want to format it to print in the entire paper as a neat format. Got it?
              Thanks, that's much clearer.

              I think you might have to print the controls yourself, to the Printer object. For example, here's a very crude Sub which you can pass a form to, and it will attempt to print all labels and picture boxes on the form... Have a play with this, you should be able to adjust the scaling and so on. When I tried it it worked, but came out a bit funny.
              Code:
              Public Sub PrintThisForm(frm As Form)
                Dim ctl As Control
                With Printer
                  .Orientation = vbPRORPortrait
                  Printer.Scale (0, 0)-(frm.ScaleWidth, frm.ScaleHeight)
                  For Each ctl In frm.Controls
                    If TypeOf ctl Is Label Then
                      .CurrentX = ctl.Left
                      .CurrentY = ctl.Top
                      .Font = ctl.Font
                      .ForeColor = ctl.ForeColor
                      Printer.Print ctl.Caption
                    ElseIf TypeOf ctl Is PictureBox Then
                      .PaintPicture ctl.Image, ctl.Left, ctl.Top
                    End If
                  Next
                  .EndDoc
                End With
              End Sub

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                It might also help to read some relevant articles such as Expand Your VB6 Printing Repertoire—Part I.

                Comment

                • arunbalait
                  New Member
                  • Feb 2007
                  • 164

                  #9
                  ya thanx.. But I calculated the Horizontal and Veritcal margins and printed the cotrols. But I coulndt get clear formatting. Somehow nearer.

                  Comment

                  Working...