Article ID: 129748
Article Last Modified on 1/19/2007
Type str_DevMode
RGB As String * 512
End Type
For more information about PrtDevMode settings in Windows 95 or later,
please see the following article in the Microsoft Knowledge Base:
140286 ACC2: PrtDevMode Settings Do Not Work Under Windows 95 or Later
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
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, AcViewDesign
'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>"
Keywords: kbinfo kbprint kbprogramming KB129748