Я хочу установить постоянный размер бумаги отчета A3, когда пользователь печатает ее с помощью кода VBA.Для этого я написал этот код, который нашел по сети
Option Compare Database
Type gtypStr_DEVMODE
RGB As String * 94
End Type
Type gType_DEVMODE
strDeviceName As String * 32
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 * 32
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Sub SetToA3(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 = 256
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
Но он вообще не работает, т.е. когда я вызываю процедуру SettoA3, ничего не происходит.
Почему бы и нет?