Printer.Print Questions

This Is a 2 part question. #1) I want to print a textbox.text to a certain paper location. I use printer.currentx and printer.currenty to specify, but I want my text to be centered there, not start there. How do I center align my text to this location?   #2)How do I specify Font Name? I call for a font named "BlackChance" using printer.font and/or printer.fontname and it still prints text in "Arial".  Any Help Would Be Apreciated....Points May ALso Be Increased for dificulties.
rhankins99Asked:
Who is Participating?
 
tirupur_selvaConnect With a Mentor Commented:
Hi,
   Put the following code in a module. Position the printer with the CurrentY property and call the below function with the essential parameters.  

Public Function PadC(PadString$, Lenth%)
    Dim strRet$
    If Len(PadString) < Lenth Then
        strRet = Space((Lenth - Len(PadString)) / 2) + PadString
        PadC = strRet + Space(Lenth - Len(strRet))
    Else
        PadC = Left(PadString, Lenth)
    End If
End Function

I hope this would be useful.
Regs
Selva
0
 
RuchiCommented:
try this one (I have not tried to test it)

Private Sub Command2_Click()
Dim MYTEXT As String

Printer.FontName = "BlackChance"
Printer.CurrentX = (Printer.Width / 2) - (TextWidth(MYTEXT) / 2)
Printer.CurrentY = (Printer.Height / 2) - (TextHeight(MYTEXT) / 2)
MYTEXT = "This is centered"
Printer.Print MYTEXT
Printer.EndDoc

0
 
RuchiCommented:
oops...

this is the correct one.

Private Sub Command2_Click()
Dim MYTEXT As String

Printer.FontName = "BlackChance"
MYTEXT = "This is centered"
Printer.CurrentX = (Printer.Width / 2) - (TextWidth(MYTEXT) / 2)
Printer.CurrentY = (Printer.Height / 2) - (TextHeight(MYTEXT) / 2)

Printer.Print MYTEXT
Printer.EndDoc
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
rhankins99Author Commented:
This does center the text to the page, but not to the location specified. (Ex. current x = 1" current y =3") I want to center a textbox1.text at current x and current y. and a textbox2.text at another current x and current y(ex. x = 3" and y = 3") The text is input by the user which is 2-10 characters. Text must be centered at x, y LOCATIONS, not center page.  
0
 
rhankins99Author Commented:
Adjusted points to 37
0
 
tirupur_selvaCommented:
for the second part of your question, increase more points.
0
 
rhankins99Author Commented:
Adjusted points to 50
0
 
moterkCommented:
Let (xpos, ypos) be the (x, y) point about which you want your text centered.  And mytext be a string var containing the text to be centered.

With Printer
..CurrentX =xpos-(.TextWidth(mytext)/2)
..CurrentY =ypos-(.TextHeight(mytext)/2)
..print mytext
End With

Should center the text where you want it.
0
 
moterkCommented:
For some reason an extra . showed up before the CurrentX, CurrentY, and Print
0
All Courses

From novice to tech pro — start learning today.