Solved

Printing format Problems

Posted on 2004-10-11
1
194 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 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…

749 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