Solved

Printed Page Margins - revisited

Posted on 1998-08-13
3
208 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
[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
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

733 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