| Menuへ | ||||
| 超シンプルなはがき印刷ソフトを作ってみよう | ||||
Step 8 「印刷」「中止」ボタンの追加 |
||||
| シートコード | ||||
| 下記のコードを追加してください Option Explicit '停止フラッグ Private StopFlag As Boolean 'Windowsが起動してからの経過時間 API Private Declare Function GetTickCount Lib "kernel32" () As Long 'タイマー Private Sub ExTimer(tim As Long) Dim st As Long tim = tim * 1000 '開始時間を取得 st = GetTickCount DoEvents Do If GetTickCount - st >= tim Then '時間が経過した Exit Do End If DoEvents Loop End Sub Private Sub CommandButton2_Click() ExPrint 1 End Sub Private Sub CommandButton3_Click() StopFlag = True End Sub 下記のコードに変更してください '印刷の開始 Private Sub ExPrintStart(mode As Integer) Dim lrow As Long Dim j As Long StopFlag = False CommandButton1.Enabled = False CommandButton2.Enabled = False CommandButton3.Enabled = True DoEvents lrow = ExLastRow For j = 10 To lrow If ActiveSheet.Cells(j, 2) <> "" Then ExPrintDataSet j End If If mode = 1 Then Sheets("はがき表").PrintOut Else Sheets("はがき表").PrintPreview End If If StopFlag = True Then Exit For End If ExTimer 1 If StopFlag = True Then Exit For End If Next CommandButton1.Enabled = True CommandButton2.Enabled = True CommandButton3.Enabled = False End Sub |
||||
| 実行結果 | ||||
|
||||
| Topへ |
||||
| ■このサイトの内容を利用して発生した、いかなる問題にも一切の責任は負いませんのでご了承下さい。■ 当ホームページに掲載されているあらゆる内容の無許可転載・転用を禁止します。 Copyright (c) 2006 excel_ninpou All rights reserved. |
||||