Solved

VB Print Problems Again

Posted on 2003-10-24
3
332 Views
Last Modified: 2012-05-04
I'm doing a simple print out of text and I cannot get the left margin to work (using Printer.CurrentX = 1440).  I can move the text down with Printer.CurrentY but cannot move it in from the left.  (see code)  Incidentally, the CurrentY moves the text down about 2 inches, not the 1 inch I expected for 1440 twips.  Why?

Also, I defined the Greek letter, nu, as ChrW$(957) in my code, but it won't print with the code below.  I get a '?' on the printout where the nu should be.  The nu letter is in the lbl1resultCaption:

Dim nu As String
nu = ChrW$(957)
lblResult1Caption.Caption = "Liquid " & nu & " (ft" & super3 & "/lbm)"

This is the printer code:

PrinterDefault = True
   
    Printer.PaperSize = vbPRPSLetter
    Printer.FontName = "TimesRoman"
    Printer.FontSize = 12
    Printer.CurrentX = 1440
    Printer.CurrentY = 1440
    Debug.Print
    Debug.Print "Printer.CurrentX = " & Printer.CurrentX
    Debug.Print "Printer.CurrentY = " & Printer.CurrentY
   
    Printer.Print
    Printer.Print lblProductName
    Printer.Print lblCopyright
    Printer.Print lblVersion
   
    Printer.Print
    Printer.Print "Pressure (psia) = " & txtPressure.Text
    Printer.Print "Temperature (degrees F) = " & txtTemperature.Text
    Printer.Print
    Printer.Print "Tsat (degrees F) = " & lblOutTsatValue.Caption
    Printer.Print "Tmetastable (degrees F) = " & lblOutTmetaValue.Caption
    Printer.Print
   
    If lblResult1.Visible = True Then
        Printer.Print lblResult1Caption & " = " & lblResult1
    End If
    If lblResult2.Visible = True Then
        Printer.Print lblResult2Caption & " = " & lblResult2
    End If
    If lblResult3.Visible = True Then
        Printer.Print lblResult3Caption & " = " & lblResult3
    End If
    If lblResult4.Visible = True Then
        Printer.Print lblResult4Caption & " = " & lblResult4
    End If
    If lblResult5.Visible = True Then
        Printer.Print lblResult5Caption & " = " & lblResult5
    End If
    If lblResult6.Visible = True Then
        Printer.Print lblResult6Caption & " = " & lblResult6
    End If
    Printer.EndDoc

Thanks, Jake67
0
Comment
Question by:jake67
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 125 total points
ID: 9651373
Hi Jake

There is a problem with your code. Setting the currentX value will only set a margin for the next line printed i.e. if you try to print a second line it will move to the left.

To overcome this you need to set the currentx value before printing each value. For example

printer.currentx =  1440
printer.print "Hello"
printer.currentx=1440
printer.print "World"

The only alternative to this is to use the semicolon ';' after each printed value. This works by surpressing the line feed thereby keeping the printer on the current line e.g

printer.currentx =  1440
printer.print "Hello";
printer.print "World"


0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9651518
Your Greek letter nu, not totally sure about this one but it could be because the font set that you are using i.e. Arial or Times New Roman does not support Greek letters (do you have a Greek font set installed). The font can be changed with the command:

 Printer.fontname = "Fontname"
0
 

Author Comment

by:jake67
ID: 9674049
Thanks, Tom.

The explanation of currentX setting only the margin for the next line was right on.  As to the Greek letter, nu, I'll have to work on that.  I can get it to display properly on the screen, but not print.

Jake
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

13 Experts available now in Live!

Get 1:1 Help Now