Solved

Printing a form with texts in VB 5

Posted on 2002-07-19
3
145 Views
Last Modified: 2010-05-02
"object.PrintForm" prints the active forms.
But I want to print few text, suppose "My Name" on the paper before the form is printed.
Can I do it with "PrintForm" function or there is any other function in VB 5.0 where we can add few text before printing the form?
There form will be printed as shown, but in the header or footer of the form, the text should be printed.  The form is a child form not an MDI.
0
Comment
Question by:saroopchand
3 Comments
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
How about a label that's got Visible=False? Put the label at design time where you want "My Name" to appear and then you could try:

   Sub MyPrintForm

      Label1 = "My Name"
      Label1.Visible = True
      Me.PrintForm
      Label1.Visible = False

   End Sub
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 50 total points
Comment Utility
put an invisble picture box on your form:
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source


Private Sub Command1_Click()

Dim retVal As Integer
Picture1.Visible = False
Picture1.AutoRedraw = True
Picture1.ScaleMode = 3
Picture1.Width = Me.ScaleWidth
Picture1.Height = Me.ScaleHeight

'' now write to Printer hdc
retVal = BitBlt(Picture1.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, _
         Me.hDC, 0, 0, SRCCOPY)

Printer.PaintPicture Picture1.Image, 5, 5
Printer.CurrentY = Picture1.Height
Printer.Print "footer"
Printer.EndDoc

End Sub
0
 

Author Comment

by:saroopchand
Comment Utility
Yes, it works perfectly.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now