Microsoft KB Archive/302650

= ACC97: How to Print on Legal-Size Paper in Landscape Mode =

Article ID: 302650

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q302650



Moderate: Requires basic macro, coding, and interoperability skills.

For a Microsoft Access 2000 version of this article, see 302416.



SUMMARY
This article describes how to create a Visual Basic module (PrintDevMode) to format a report so that you can print or preview the report in Landscape mode on legal-size paper. The instructions in the article include code for a command button that opens the formatted report.



MORE INFORMATION
To print or preview a report in Landscape mode on 8.5-by-14-inch (legal-size) paper, create the following module:  In Access, press ALT+F11 to start the Visual Basic Editor.  On the Insert menu, click Module, and then add the following code to the new module: Type str_DEVMODE RGB As String * 94 End Type

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

Public Function SetLegalSize(strName As String) Dim rpt As Report Dim strDevModeExtra As String Dim DevString As str_DEVMODE Dim DM As type_DEVMODE

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.lngFields = DM.lngFields Or DM.intOrientation 'Initialize fields. DM.intPaperSize = 5 'Legal size DM.intOrientation = 2 'Landscape LSet DevString = DM 'Update property. Mid(strDevModeExtra, 1, 94) = DevString.RGB rpt.PrtDevMode = strDevModeExtra DoCmd.Save acReport, strName DoCmd.Close acReport, strName End If

End Function   Add the following code to an On Click event for a command button: SetLegalSize(&quot; &quot;) DoCmd.OpenReport &quot; &quot;, acViewPreview 

Additional query words: inf

Keywords: kbhowto kbprint kbprogramming KB302650

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.