Solved

Printed Page Margins - revisited

Posted on 1998-08-13
3
201 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
Comment Utility
  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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

771 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

15 Experts available now in Live!

Get 1:1 Help Now