Solved

VB Print Problems Again

Posted on 2003-10-24
3
343 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

856 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