Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing 1

Status
Not open for further replies.

huBBLe

Programmer
May 15, 2001
50
0
0
SG
I'm using frmMyForm.PrintForm to do the printing but it doesn't fill up the whole page. I understnad that another way is to transfer all the controls onto a picture box and then print the picture box. However, this will require too much of a trouble as I have abt 200 - 300 over controls on one form alone, and i have abt 10 forms.

I need a way to scale the form to fill and fit the paper, is there any way i can achieve this?

Oh and another thing! I used SSTab for all of my forms and i can only print one Tab for every PrintForm that I call. Any way i can print the tabs at one go?

Thank You
 
I got this routine from (it is a GREAT site for some pretty cool routines). I have since replaced all of my form prints (typically
Me.PrintForm) with this routine, and I really like the results.

In the declarations section of your form, put:

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

In the click event of the button that does the print, put:

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

This routine was written by, and posted by, Matt Hart

As far as your question about the Tabs, the only thing I can suggest is that you send the form to print, then programmatically "click" the next tab (i.e., SSTab.Tab = 1, etc), and send it to print again.

I hope this helps somewhat.
 
thanks hackster! that was a pretty cool site indeed. unfortunately, the routine does not accomplish wat i want.

this routine does not scale the form to fit the paper like i wanted to. in fact, the effect is the same as that of PrintForm.

the printout looks really ugly wif the form all cropped up in the top left corner of the paper.

does anyone else has any idea to do a scale to fit?

i remember MS PowerPoint has a function which prints out slides and it offers an option to scale to fit the paper...maybe i can access this property of PP using automation? anyone who can help?
 
I GOT IT!!

did some twiddling around and found out that i can actually scale the picture simply by changing the parameters "width" and "height" of the paintpicture method. (DUH!!)

didn't noticed the paintpicture method the first time round. took some trial n error to correctly size the form to fit though.

Thanks Hackster!!! you're a gem!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top