⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm_print.frm

📁 关于图书馆管理的vfp程序
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Frm_Print 
   Caption         =   "打印输出"
   ClientHeight    =   4590
   ClientLeft      =   4110
   ClientTop       =   3615
   ClientWidth     =   6795
   LinkTopic       =   "Form1"
   ScaleHeight     =   4590
   ScaleWidth      =   6795
   Begin MSDataGridLib.DataGrid dataGridRetrive 
      Bindings        =   "Frm_Print.frx":0000
      Height          =   4335
      Left            =   120
      TabIndex        =   5
      Top             =   120
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   7646
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSAdodcLib.Adodc AdoRetrive 
      Height          =   375
      Left            =   120
      Top             =   3240
      Visible         =   0   'False
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSComDlg.CommonDialog cdlPrint 
      Left            =   1920
      Top             =   2880
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdExcelPrint 
      Caption         =   "EXCEL打印输出"
      Height          =   495
      Left            =   4920
      TabIndex        =   4
      Top             =   1110
      Width           =   1815
   End
   Begin VB.CommandButton cmdMSWordPrint 
      Caption         =   "MS_WORD打印输出"
      Height          =   495
      Left            =   4920
      TabIndex        =   3
      Top             =   2100
      Width           =   1815
   End
   Begin VB.CommandButton cmdDataRptPrint 
      Caption         =   "数据报表打印输出"
      Height          =   495
      Left            =   4920
      TabIndex        =   2
      Top             =   3090
      Width           =   1815
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   495
      Left            =   4920
      TabIndex        =   1
      Top             =   4080
      Width           =   1815
   End
   Begin VB.CommandButton cmdProgramPrint 
      Caption         =   "编程打印输出"
      Height          =   495
      Left            =   4920
      TabIndex        =   0
      Top             =   120
      Width           =   1815
   End
End
Attribute VB_Name = "Frm_Print"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MSWord As Object

Public Sub cmdDataRptPrint_Click()
Dim rtn As Integer
rtn = MsgBox("此为全部打印,将要输出打印所有信息吗?", vbOKCancel + vbInformation, "打印信息")
    If rtn = vbCancel Then
Exit Sub
End If
DataEmt.CntPrint.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\book.mdb"
DataRptBookPrint.Show
DataRptStuPrint.Show
End Sub

Private Sub cmdExcelPrint_Click()
Dim xlApp, xlBook, xlSheet
Dim i As Integer, j As Integer
Set xlApp = CreateObject("excel.application")
xlApp.Visible = True
Set xlBook = xlApp.workbooks.Add
Set xlSheet = xlBook.worksheets(1)
For j = 0 To dataGridRetrive.Columns.Count - 1
    xlSheet.cells(1, j + 1) = AdoRetrive.Recordset.Fields(j).Name
Next j
AdoRetrive.Recordset.MoveFirst
i = 1
Do While Not AdoRetrive.Recordset.EOF
    For j = 0 To dataGridRetrive.Columns.Count - 1
        dataGridRetrive.Col = j
        If Not IsNull(dataGridRetrive.Text) Then
            xlSheet.cells(i + 1, j + 1) = AdoRetrive.Recordset(j)
        End If
    Next j
    AdoRetrive.Recordset.MoveNext
    i = i + 1
Loop
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdMSWordPrint_Click()
Dim AppID
On Error GoTo Error
Set MSWord = CreateObject("word.basic")
AppID = Shell("D:\Microsoft Office\Office10\winword")
DataTrans
Exit Sub
Error:
    MsgBox "你已经打开了要打印的了一份!!" & Chr(13) & "要想另外打开新的一份,请先关闭打开的所有Word文挡", vbExclamation, "打印信息"
    Unload Me
End Sub

Private Sub DataTrans()
Dim i As Integer, j As Integer
MSWord.tableinserttable , dataGridRetrive.Columns.Count, AdoRetrive.Recordset.RecordCount, , , 16, 167
For j = 0 To dataGridRetrive.Columns.Count - 1
    MSWord.Insert AdoRetrive.Recordset.Fields(j).Name
    MSWord.nextcell
Next j
AdoRetrive.Recordset.MoveFirst
Do While Not AdoRetrive.Recordset.EOF
    For j = 0 To dataGridRetrive.Columns.Count - 1
        If IsNull(AdoRetrive.Recordset.Fields(j).Value) Then
            MSWord.Insert ""
        Else
            MSWord.Insert AdoRetrive.Recordset.Fields(j).Value
            MSWord.nextcell
        End If
    Next j
    AdoRetrive.Recordset.MoveNext
Loop
MSWord.tabledeleterow
End Sub

Private Sub cmdProgramPrint_Click()
Dim i As Integer, j As Integer
On Error Resume Next
cdlPrint.ShowPrinter
For i = 0 To cdlPrint.Copies
    For j = 0 To AdoRetrive.Recordset.RecordCount
        Printer.Print AdoRetrive.Recordset(j)
    Next j
Next i
Printer.EndDoc
End Sub

Private Sub Form_Load()
Dim mpath As String, mlink As String
mpath = App.Path
If (Right(mpath, 1) <> " \") Then mpath = mpath + "\"
mlink = "provider=microsoft.jet.oledb.3.51;data source=" + mpath + "book.mdb"
AdoRetrive.ConnectionString = mlink
AdoRetrive.RecordSource = SQL
AdoRetrive.Refresh
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -