[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Printing format Problems

Posted on 2004-10-11
1
Medium Priority
?
213 Views
Last Modified: 2010-05-02
Hi:
    When I use Debug.Print with the following code; the output is correctly formatted but when I use Printer.Print I lose the formatting(does not align at the decimal point). Can someone tell me why this happens and how to fix it?

 Private Sub cmdPrint_Click()
Dim strPS As String * 7, strPS2 As String * 7, strPS3 As String * 7
 
 
 RSet strPS = Format(564, "##,###.")
 RSet strPS2 = Format(777, "##,###.")
 RSet strPS3 = Format(902, "##,###.")
 Printer.Print strPS, strPS2, strPS3
 'Debug.Print strPS, strPS2, strPS3
 
 RSet strPS = Format(4500, "##,###.")
 RSet strPS2 = Format(888, "##,###.")
 RSet strPS3 = Format(9, "##,###.")
 Printer.Print strPS, strPS2, strPS3
 'Debug.Print strPS, strPS2, strPS3
 
 RSet strPS = Format(4, "##,###.")
 RSet strPS2 = Format(59, "##,###.")
 RSet strPS3 = Format(34556, "##,###.")
 Printer.Print strPS, strPS2, strPS3
 'Debug.Print strPS, strPS2, strPS3
 Printer.EndDoc
 
End Sub

0
Comment
Question by:LearningJava
1 Comment
 
LVL 3

Accepted Solution

by:
Noel_Castillo earned 1200 total points
ID: 12283295
The immediate window actually does the allignment for you during debug.print and not your code. Theres nothing wrong with your code. Its your printers font that disalligns your figures. most fonts perform kerning-compressing the letters to obtain smallest width possible. ex comma has smaller width comapare to figure # 9. But there are still some other fonts that has a uniform width for all its character set. like 'Courier New' & 'Fixedsys'
Try to add this code on top before printing and I hope this helps. :)

 For i = 0 To Printer.FontCount - 1
    If Printer.Fonts(i) = "Courier New" Then
        Printer.Font = Printer.Fonts(i)
        Exit For
    End If
 Next

...
...
do your printer.print here
...
...


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

873 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