Solved

Printing format Problems

Posted on 2004-10-11
1
161 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 400 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

9 Experts available now in Live!

Get 1:1 Help Now