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
intDriverVersio n 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
intDefaultSourc e 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(s trName 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_SwitchtoLeg al
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.OpenRepor t strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName )
If Not IsNull(rpt.PrtD evMode) 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.intOrientati on ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeE xtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnin gs False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnin gs True
DoCmd.Echo True, ""
Exit_SwitchtoLe gal:
Exit Sub
Err_SwitchtoLeg al:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description , vbInformation + vbOKOnly,
"SwitchtoLe gal"
Resume Exit_SwitchtoLe gal
End Select
End Sub