I got the following code from an earlier posting (much earlier, like 1999)
in this ng. This is supposed to control the paper size selected to legal,
even if the default printer changes. Question is where do I stick this code,
so that my calling function can see it? In the form from which I print the
report?
TIA.
Brian
Option Compare Database
Option Explicit
Type gtypStr_DEVMODE
RGB As String * 94
End Type
Type gType_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
Sub SwitchtoLegal(strName As String)
' Comments : Switches paper size to legal, regardless of original
setting
' Parameters : strName - contains the name of the report
' Returns : Saves report with new legal setting. User needs mod perm
' Created : Received from Brian Ward, 3/12/1999
' Modified : Kim Jacobson 3/12/1999
'
' --------------------------------------------------------
'Call the procedure like this:
' Dim strDocName As String
' strDocName = "Report Name Here"
' SwitchtoLegal (strDocName)
' --------------------------------------------------------
On Error GoTo Err_SwitchtoLegal
Dim DevString As gtypStr_DEVMODE
Dim DM As gType_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
DoCmd.Echo False, "Checking default printer settings..."
DoCmd.OpenReport strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intPaperSize = 5 'set to legal, standard would be 1
'DM.lngFields = DM.lngFields Or DM.intOrientation ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnings False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnings True
DoCmd.Echo True, ""
Exit_SwitchtoLegal:
Exit Sub
Err_SwitchtoLegal:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description, vbInformation + vbOKOnly,
"SwitchtoLegal"
Resume Exit_SwitchtoLegal
End Select
End Sub