ACC: Using the PrtDevMode Property to Verify Custom Page SizeLast reviewed: August 29, 1997Article ID: Q129748 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. When you use the PrtDevMode property, keep the following printer driver characteristics in mind. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual. NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access version 2.0. For more information about Access Basic, please refer to the "Building Applications" manual.
To create the Sub procedure, follow these steps: NOTE: If you are using Microsoft Access 2.0 on a computer running Windows 95, you will need to modify the Type statement in step 1 to read as follows:
Type str_DevMode
RGB As String * 512
End Type
For more information about PrtDevMode settings in Windows 95, please see
the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q140286 TITLE : ACC2: PrtDevMode Settings Do Not Work Under Windows 95 Option Explicit 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
NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
Sub CheckCustomPage (rptName As String)
' The zwtDevModeStr and zwtDeviceMode types are defined in the
' zwAllGlobals module in the WZFRMRPT.MDA file.
Dim DevString As zwtDevModeStr
Dim DM As zwtDeviceMode
'Constants for the Fields member.
Const DM_PAPERSIZE = &H2
Const DM_PAPERLENGTH = &H4
Const DM_PAPERWIDTH = &H8
Dim DevModeExtra As String
Dim rpt As Report
Dim response
Dim msg As String
'Open the report in Design view.
DoCmd.OpenReport rptName, A_DESIGN
'DoCmd OpenReport rptName, A_DESIGN (in Microsoft Access 2.0)
Set rpt = Reports(rptName)
If Not IsNull(rpt.PrtDevMode) Then
'Copy the PrtDevMode property to a string.
DevModeExtra = rpt.PrtDevMode
DevString.rgb = DevModeExtra
LSet DM = DevString
'Check for the custom page size.
If DM.dmPaperSize = 256 Then
'Display the custom page size.
msg = "The Custom Page Size is " & DM.dmPaperWidth / 254
msg = msg & " inches wide by " & DM.dmPaperLength / 254
msg = msg & " inches long. Change the size?"
response = MsgBox(msg, 4)
Else
msg = "The report does not have a custom page. "
msg = msg & " Do you want to define one?"
response = MsgBox(msg, 4)
End If
If response = 6 Then
'User chose Yes; change the size.
'Initialize the Fields member.
DM.dmFields = DM.dmFields Or DM_PAPERSIZE Or _
DM_PAPERLENGTH Or DM_PAPERWIDTH
'Set the page size.
DM.dmPaperSize = 256
msg = "Please enter Page Length in inches"
DM.dmPaperLength = InputBox(msg) * 254
msg = "Please enter Page Width in inches"
DM.dmPaperWidth = InputBox(msg) * 254
'Update the first 68 bytes of the PrtDevMode property.
LSet DevString = DM
Mid$(DevModeExtra, 1, 68) = DevString.rgb
rpt.PrtDevMode = DevModeExtra
End If
End If
End Sub
CheckCustomPage "<Report1>" where <Report1> is the name of your report. Note that the report opens in Design view, the custom page size (if it exists) is displayed, and you are prompted to change it.
REFERENCESFor more information about using PrtDevMode, search the Help Index for "PrtDevMode," or ask the Microsoft Access 97 Office Assistant. Keywords : kbprg kbprint PgmHowTo RptProp Version : 2.0 7.0 97 Platform : WINDOWS Hardware : x86 Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |