Office中国论坛/Access中国论坛

标题: 请帮忙分析Access2000下报表自定义纸型的代码 [打印本页]

作者: WTM1    时间: 2002-10-11 22:00
标题: 请帮忙分析Access2000下报表自定义纸型的代码

--------------------------------------------------------------------------------

自定义部分
Option Compare Database
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
下列代码是要自定义Access2000数据库中报表打印纸纸型的,在运行中有时会出现
回到打印机默认纸型(打印nec2000)而且有时出现Access停滞的现象(需要修复方可使用)。由于我是初学者,试过不少办法不得其法。请您指出缺点或提供一些VBA的资料。
多谢了
Private Sub 命令6_Click()
  On Error GoTo Err_命令6_Click
   Dim StDocName As String
   StDocName = "报表"
   Dim DevString As str_DEVMODE
   Dim DM As type_DEVMODE
   Dim strDevModeExtra As String
   Dim rpt As Report
   Dim intResponse As Integer
   DoCmd.OpenReport StDocName, acDesign
   Set rpt = Reports(StDocName)
   If Not IsNull(rpt.PrtDevMode) Then
       strDevModeExtra = rpt.PrtDevMode
       DevString.RGB = strDevModeExtra
       LSet DM = DevString
       If DM.intPaperSize <> 256 Then
       DM.lngFields = DM.lngFields Or _
            DM.intPaperSize Or DM.intPaperLength _
               Or DM.intPaperWidth Or DM.intOrientation
           DM.intPaperSize = 256   ' Set custom page.
           DM.intOrientation = 1
           DM.intPaperLength = 5.5 * 254
           DM.intPaperWidth = 8.5 * 254
           LSet DevString = DM         
           Mid(strDevModeExtra, 1, 94) = DevString.RGB
           rpt.PrtDevMode = strDevModeExtra
       End If
   End If
  DoCmd.Close acReport, StDocName, acSaveYes
   DoCmd.OpenReport StDocName, acPreview, , "[时间]=FORMs![主窗体]![时间]"
   Exit_命令6_Click:
   Exit Sub

Err_命令6_Click:
   MsgBox Err.Description
   Resume Exit_命令6_Click






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3