注册 登录
Office中国论坛/Access中国论坛 返回首页

5988143的个人空间 http://www.office-cn.net/?10050 [收藏] [复制] [分享] [RSS]

日志

will change the orientation of the report, according to the parameter

已有 2558 次阅读2009-2-10 12:21 |

1. SwitchOrient(report_name)
   This will set the orientation of report_name to Landscape ALLWAYS.
2.SwitchOrient(report_name, [DM_LANDSCAPE | DM_PORTRAIT])
   This will set the orientation of report_name to either Portrait or Landscape, according to the second parameter's value (1 or 2, see the const declaration bellow).
 
 
Public Const DM_PORTRAIT = 1
Public Const DM_LANDSCAPE = 2

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 Sub SwitchOrient(strName As String, Optional ToOrient As Byte = DM_LANDSCAPE)
   Dim DevString As str_DEVMODE
   Dim DM As type_DEVMODE
   Dim strDevModeExtra As String
   Dim rpt As Report
   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.
       If DM.intOrientation <> ToOrient Then
           DM.intOrientation = ToOrient
       End If
       LSet DevString = DM                     ' Update property.
       Mid(strDevModeExtra, 1, 94) = DevString.RGB
       rpt.PrtDevMode = strDevModeExtra
   End If
   '----- To Close & Save the Report
   DoCmd.Close acReport, strName, acSaveYes 'Close and save
End Sub

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-12-26 23:00 , Processed in 0.052404 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部