I'm trying to print a report using legal size. But each time I changed the papersize in page setup, it defaults back to letter? Can anyone help. This is Access 97 please.
Also, I have some code to make it print with legal size but it's not working as well. Please look at code.
Public Type str_DEVMODE
RGB As String * 94
End Type
Public Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer
intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Private Sub btnRepurchaseAuthorizationFormPrint_Click()
Dim rpt As Report
Dim mdl As Module
Const DM_PORTRAIT = 1
Const DM_LANDSCAPE = 2
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
DoCmd.OpenReport "RepurchaseAuthorizationReport", acViewDesign
Set rpt = Reports("RepurchaseAuthorizationReport"
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.lngFields = DM.lngFields Or DM.intPaperSize Or DM.intPaperLength Or DM.intPaperWidth
DM.intPaperSize = 5 ' Set Legal page. <- Here is where you set paper type
LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
DoCmd.Save acReport, rpt.Name
DoCmd.SelectObject acReport, rpt.Name ', True
DoCmd.OpenReport "RepurchaseAuthorizationReport", acViewPreview
'DoCmd.PrintOut acPrintAll ', 2, 2
'DoCmd.Close ' Closes the report
End If
End Sub
Also, I have some code to make it print with legal size but it's not working as well. Please look at code.
Public Type str_DEVMODE
RGB As String * 94
End Type
Public Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer
intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Private Sub btnRepurchaseAuthorizationFormPrint_Click()
Dim rpt As Report
Dim mdl As Module
Const DM_PORTRAIT = 1
Const DM_LANDSCAPE = 2
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
DoCmd.OpenReport "RepurchaseAuthorizationReport", acViewDesign
Set rpt = Reports("RepurchaseAuthorizationReport"
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.lngFields = DM.lngFields Or DM.intPaperSize Or DM.intPaperLength Or DM.intPaperWidth
DM.intPaperSize = 5 ' Set Legal page. <- Here is where you set paper type
LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
DoCmd.Save acReport, rpt.Name
DoCmd.SelectObject acReport, rpt.Name ', True
DoCmd.OpenReport "RepurchaseAuthorizationReport", acViewPreview
'DoCmd.PrintOut acPrintAll ', 2, 2
'DoCmd.Close ' Closes the report
End If
End Sub