Click to See Complete Forum and Search --> : Center Print


Ace Jones
April 15th, 2001, 05:34 PM
Hi Everyone,

I have a couple of text boxes and labels that I would like to have printed down the center of a standard piece of paper, but have no idea how to accomplish this. I would appreciate any help. Thank you.

I.L. Iterate
April 15th, 2001, 07:05 PM
I believe it would go something like this...

label.top=(screen.height-label.height)/2
label.left=(screen.width-label.width)/2

I think that if you set the form this way as well you should get the desired effect.
If I've misinterpreted your question, send me a message.

Chris

Iouri
April 16th, 2001, 07:04 AM
Private Sub Command1_Click()
'==========================
Dim sStr As String
Dim iPageWidth As Integer

sStr = "aaa"
iPageWidth = 80 'if font <>12 then pagewidth is different from 80
Printer.Font = "Courier"
Printer.FontSize = 12
Printer.Print CenterString(iPageWidth, sStr)
Printer.NewPage
Printer.EndDoc
End Sub

Private Function CenterString(ByVal iCharOnPage As Integer, ByVal sString As String) As String
'=============================================================================
CenterString = Left(Space(iCharOnPage / 2), Len(Space(iCharOnPage / 2)) - Len(sString) / 2) & sString
End Function


Iouri Boutchkine
iouri@hotsheet.com

RobZeilinga
April 17th, 2001, 06:44 AM
You can also center each item:


' to Center the contents of myStr
myStr = "Center This"
'get the width of the string in twips
txtW = Printer.TextWidth(myStr)
'Divide this answer by 2
MyMid = txtW/2
'Calculate the middle of the Printed page
paperMid = Printer.Scalewidth/2
'Subtract the middle of the text (MyMid) from PaperMid
txtStart = paperMid - MyMid
'set the print Co-Ords
Printer.CurrentX = txtStart
'The .CurrentY will be set From Previous print Commands or 0
'The next Command will print the string exactly in the middle of the page
Printer.print
' If you want middle from top to bottom, Replace Printer.TextWidth with
' Printer.TextHeight and .ScaleWidth with .ScaleHeight




Hope this helps
RobZ

Printer.Print myStr