List 7-47 FormPrintPreviewフォームのBTN_PRT_Clickプロシージャ


  1: Private Sub BTN_PRT_Click()
  2:     ' [印刷]ボタンを押したときの処理
  3:     Dim fromPage As Long, toPage As Long, bAll As Boolean
  4:     
  5:     ' 自分自身を閉じる
  6:     Me.Hide
  7:     
  8:     ' 印刷ページの設定状況を得る
  9:     fromPage = 1
 10:     toPage = g_MaxPage
 11:     
 12:     If FormPageSetting.GetPage(fromPage, toPage, bAll) Then
 13:         ' 印刷する
 14:         If bAll <> True Then
 15:             ' 一部のページだけ
 16:             If (fromPage < 1) Or (toPage > g_MaxPage) Or (fromPage > toPage) Then
 17:                 MsgBox "ページ範囲の設定が不正です", vbOKOnly, "ページ設定エラー"
 18:                 Exit Sub
 19:             End If
 20:         Else
 21:             ' すぺてのページ
 22:             fromPage = 1
 23:             toPage = g_MaxPage
 24:         End If
 25:         
 26:         ' プリンタをTwips単位にしてから印刷する
 27:         Printer.ScaleMode = vbTwips
 28:         DrawPreview Printer, fromPage, toPage
 29:     End If
 30: End Sub