Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Report Print Dimensions 1

Status
Not open for further replies.

TimTDP

Technical User
Feb 15, 2004
373
ZA
In Access 2000, how can I get the dimensions of a report via VB code?
I would like to know the paper size and margins
 
This is modified from Help.

Code:
Option Compare Database
Option Explicit
                    
Type str_PRTMIP
    strRGB As String * 28
End Type
Type type_PRTMIP
    xLeftMargin As Long
    yTopMargin As Long
    xRightMargin As Long
    yBotMargin As Long
    fDataOnly As Long
    xWidth As Long
    yHeight As Long
    fDefaultSize As Long
    cxColumns As Long
    yColumnSpacing As Long
    xRowSpacing As Long
    rItemLayout As Long
    fFastPrint As Long
    fDatasheet As Long
End Type

Type zwtDevModeStr
    RGB As String * 94
End Type

Type zwtDeviceMode
    dmDeviceName As String * 16
    dmSpecVersion As Integer
    dmDriverVersion As Integer
    dmSize As Integer
    dmDriverExtra As Integer
    dmFields As Long
    dmOrientation As Integer
    dmPaperSize As Integer
    dmPaperlength As Integer
    dmPaperWidth As Integer
    dmScale As Integer
    dmCopies As Integer
    dmDefaultSource As Integer
    dmPrintQuality As Integer
    dmColor As Integer
    dmDuplex As Integer
    dmResolution As Integer
    dmTTOption As Integer
    dmCollate As Integer
    dmFormName As String * 16
    dmPad As Long
    dmBits As Long
    dmPW As Long
    dmDFI As Long
    dmDRr As Long
End Type
                    
Sub CheckPageSize(rptName As String)
'[URL unfurl="true"]http://msdn2.microsoft.com/en-us/library/aa207072(office.10).aspx[/URL]

    Dim DevString As zwtDevModeStr
    Dim DM As zwtDeviceMode
    Dim DevModeExtra As String
    Dim rpt As Report
    
    'Open the report in Design view.
    DoCmd.OpenReport rptName, acDesign
    Set rpt = Reports(rptName)
   
    DevString.RGB = rpt.PrtDevMode
    LSet DM = DevString

    'Paper Size: [URL unfurl="true"]http://msdn2.microsoft.com/en-us/library/aa225944(office.10).aspx[/URL]
    Debug.Print DM.dmPaperSize  '9 = A4, see link
    Debug.Print DM.dmPaperlength / 10 & " mm"
    Debug.Print DM.dmPaperWidth / 10 & " mm"
   
End Sub

Sub CheckMargins(strName As String)
'[URL unfurl="true"]http://msdn2.microsoft.com/en-us/library/aa207075(office.10).aspx[/URL]
'1440 twips = 2.54 cm = 1 inch
'56.693 twips = 1 mm
    
    Dim PrtMipString As str_PRTMIP
    Dim PM As type_PRTMIP
    Dim rpt As Report
    
    DoCmd.OpenReport strName, acDesign
    Set rpt = Reports(strName)
    
    PrtMipString.strRGB = rpt.PrtMip
    LSet PM = PrtMipString
    
    Debug.Print Round(PM.yTopMargin / 56.693, 2) & " mm"
    Debug.Print Round(PM.yBotMargin / 56.693, 2) & " mm"
    Debug.Print Round(PM.xLeftMargin / 56.693, 2) & " mm"
    Debug.Print Round(PM.xRightMargin / 56.693, 2) & " mm"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top