china99boy
Registered User.
- Local time
- Today, 08:13
- Joined
- Apr 27, 2006
- Messages
- 161
Ok I found this code online, but I am not the smartest person in the world. I have create a module and insert this code in it. Then it states that I should call this subroutine. I am not sure how this will set the report to print on legal paper. I am not sure how this is suppose to play out. Exactly where do I put this subroutine?
Private Sub Command0_Click()
SetToLegal "Report1"
End Sub
This code was inserted into a module:
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 SetToLegal(pReport As String)
Dim LDevString As gtypStr_DEVMODE
Dim LDM As gType_DEVMODE
Dim LDevModeExtra As String
Dim LRpt As Report
On Error GoTo Err_Execute
'Open report in Design view
DoCmd.OpenReport pReport, acDesign
Set LRpt = Reports(pReport)
'Change paper size to legal
If Not IsNull(LRpt.PrtDevMode) Then
LDevModeExtra = LRpt.PrtDevMode
LDevString.RGB = LDevModeExtra
LSet LDM = LDevString
'5=legal, 1=standard
LDM.intPaperSize = 5
LSet LDevString = LDM
Mid(LDevModeExtra, 1, 94) = LDevString.RGB
LRpt.PrtDevMode = LDevModeExtra
End If
'Save report changes (suppress system messages temporarily)
DoCmd.SetWarnings False
DoCmd.Save acReport, pReport
DoCmd.Close acReport, pReport
DoCmd.SetWarnings True
Exit Sub
Err_Execute:
MsgBox "Changing paper size to legal failed."
End Sub
Private Sub Command0_Click()
SetToLegal "Report1"
End Sub
This code was inserted into a module:
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 SetToLegal(pReport As String)
Dim LDevString As gtypStr_DEVMODE
Dim LDM As gType_DEVMODE
Dim LDevModeExtra As String
Dim LRpt As Report
On Error GoTo Err_Execute
'Open report in Design view
DoCmd.OpenReport pReport, acDesign
Set LRpt = Reports(pReport)
'Change paper size to legal
If Not IsNull(LRpt.PrtDevMode) Then
LDevModeExtra = LRpt.PrtDevMode
LDevString.RGB = LDevModeExtra
LSet LDM = LDevString
'5=legal, 1=standard
LDM.intPaperSize = 5
LSet LDevString = LDM
Mid(LDevModeExtra, 1, 94) = LDevString.RGB
LRpt.PrtDevMode = LDevModeExtra
End If
'Save report changes (suppress system messages temporarily)
DoCmd.SetWarnings False
DoCmd.Save acReport, pReport
DoCmd.Close acReport, pReport
DoCmd.SetWarnings True
Exit Sub
Err_Execute:
MsgBox "Changing paper size to legal failed."
End Sub