Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Printing format Problems

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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