Solved

Printed Page Margins - revisited

Posted on 1998-08-13
3
206 Views
Last Modified: 2010-04-30
My application produces a printed page output. The printing is complicated, some graphics, some text. When run on various systems, sometimes the printing overshoots the margins, usually the bottom one, yielding partial printout on multiple pages.

I started with guessing that any printer could handle half inch margins. 8.5 X 11 inches is 12240 X 15840 twips. Taking 1/2 inch off (720 twips) all around gives a printing "real estate" of 10800 X 14400 twips with upper right hand corner at x=720 and y=720 twips.

Printing is scaled to fit in the 10800 X 14400 box.

I found that I had to back off, that some installations evidently had bigger margins than that.  I backed off by guessing 100 twips at a time. There has to be a more direct way to do this.

How can I use PaperSize, Height, Width, ScaleLeft, ScaleTop properties of the printer object to get "usable twip real estate" information (from the specific installation) into my source code?  If I could do that, I could take it from there. -- Norm
0
Comment
Question by:normpos
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1468781
  Dim PageWidthPixels As Long, PageHeightPixels As Long
   Dim UnPrintableAreaX As Long, UnPrintableAreaY As Long
   Dim PrintablePixelsX As Long, PrintablePixelsY As Long

   PageWidthPixels = Int(Printer.Width / Printer.TwipsPerPixelX)
   PageHeightPixels = Int(Printer.Height / Printer.TwipsPerPixelY)
   UnPrintableAreaX = PageWidthPixels - Int(Printer.ScaleWidth / Printer.TwipsPerPixelX)
   UnPrintableAreaY = PageHeightPixels - Int(Printer.ScaleHeight / Printer.TwipsPerPixelY)
   PrintablePixelsX = PageWidthPixels - UnPrintableAreaX
   PrintablePixelsY = PageHeightPixels - UnPrintableAreaY

0
 
LVL 8

Expert Comment

by:mrmick
ID: 1468782
whoops... place this just after the sample above in a procedure and call it to see the result.


   MsgBox "PageWidthPixels: " & PageWidthPixels & vbCrLf _
          & "PageHeightPixels: " & PageHeightPixels & vbCrLf _
          & "UnPrintableAreaX: " & UnPrintableAreaX & vbCrLf _
          & "UnPrintableAreaY: " & UnPrintableAreaY & vbCrLf _
          & "PrintablePixelsX: " & PrintablePixelsX & vbCrLf _
          & "PrintablePixelsY: " & PrintablePixelsY & vbCrLf
         

0
 

Author Comment

by:normpos
ID: 1468783
mrmick: Thank you! Please be available if I have further comments on this. I'll get back to you and let you know how it works. -- Norm
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

777 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