|
▼hori さん:
こんばんは。
>返事ありがとうございます。下記のように
>修正しましたが コンパイルエラー[変数が定義されてません。]
>ちょっと修正方法が?です。よろしくお願いします。
Option Explicit
Private loop_end As Boolean
Private Sub UserForm_Activate()
loop_end = False
Do Until loop_end
Label3.Caption = Now
DoEvents '←★ここがポイント
Loop
End Sub
Private Sub UserForm_Terminate()
End
End Sub
>Private Sub CommandButton1_Click()
> Call disp_open(Label1, "処理中しばらくお待ちください", 30)
> Range("A1:AF84").Select
> Call disp_proc
> DoEvents
> Range("AF84").Activate
> Call disp_proc
> DoEvents
> ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$84"
> Call disp_proc
> DoEvents
> With ActiveSheet.PageSetup
> End With
> Call disp_proc
> DoEvents
> ActiveSheet.PageSetup.PrintArea = "$A$1:$AF$84"
> With ActiveSheet.PageSetup
> .PrintHeadings = False
> Call disp_proc
> DoEvents
> .PrintGridlines = False
> Call disp_proc
> DoEvents
> .PrintComments = xlPrintNoComments
> Call disp_proc
> DoEvents
> .PrintQuality = 600
> Call disp_proc
> DoEvents
> .CenterHorizontally = False
> Call disp_proc
> DoEvents
> .CenterVertically = False
> Call disp_proc
> DoEvents
> .Orientation = xlPortrait
> Call disp_proc
> DoEvents
> .Draft = False
> Call disp_proc
> DoEvents
> .PaperSize = xlPaperA4
> Call disp_proc
> DoEvents
> .FirstPageNumber = xlAutomatic
> Call disp_proc
> DoEvents
> .Order = xlDownThenOver
> Call disp_proc
> DoEvents
> .BlackAndWhite = False
> Call disp_proc
> DoEvents
> .PrintErrors = xlPrintErrorsDisplayed
> Application.Goto Reference:="R17C4"
> End With
> Call disp_proc
> DoEvents
> Call disp_close
> Label1.Caption = ""
>loop_end = True
>DoEvents
>Unload Me
'Unload meは一回だけ記述です
>End Sub
>Private Sub CommandButton2_Click()
> loop_end = True
>DoEvents
>Unload Me
' Unload Me ←ここも不要です
>End Sub
>Private Sub CommandButton3_Click()
> Call disp_open(Label1, "処理中しばらくお待ちください", 30)
> Range("A1:BL84").Select
> Call disp_proc
> DoEvents
> Range("BL84").Activate
> Call disp_proc
> DoEvents
> ActiveSheet.PageSetup.PrintArea = "$A$1:$BL$84"
> Call disp_proc
> DoEvents
> With ActiveSheet.PageSetup
> End With
> Call disp_proc
> DoEvents
> ActiveSheet.PageSetup.PrintArea = "$A$1:$BL$84"
> With ActiveSheet.PageSetup
> Call disp_proc
> DoEvents
> .PrintHeadings = False
> Call disp_proc
> DoEvents
> .PrintGridlines = False
> Call disp_proc
> DoEvents
> .PrintComments = xlPrintNoComments
> Call disp_proc
> DoEvents
> .PrintQuality = 600
> Call disp_proc
> DoEvents
> .CenterHorizontally = False
> Call disp_proc
> DoEvents
> .CenterVertically = False
> Call disp_proc
> DoEvents
> .Orientation = xlLandscape
> Call disp_proc
> DoEvents
> .Draft = False
> Call disp_proc
> DoEvents
> .PaperSize = xlPaperA3
> Call disp_proc
> DoEvents
> .FirstPageNumber = xlAutomatic
> Call disp_proc
> DoEvents
> .Order = xlDownThenOver
> Call disp_proc
> DoEvents
> .BlackAndWhite = False
> Call disp_proc
> DoEvents
> .PrintErrors = xlPrintErrorsDisplayed
> Application.Goto Reference:="R1C1"
> Application.Goto Reference:="R17C4"
> End With
> Call disp_proc
> DoEvents
> Call disp_close
> Label1.Caption = ""
>loop_end = True
>DoEvents
>Unload Me
' Unload Me ←ここも
>End Sub
>Private Sub CommandButton4_Click()
> Dim oldPrinter As String
>
> ' 設定する前に今のプリンタを覚える
> oldPrinter = Application.ActivePrinter
> ' 任意のプリンタに変更
> Application.ActivePrinter = "Canon LBP-2810 on Ne06:"
> ' 変更があったか確認
> If Application.ActivePrinter <> oldPrinter Then
> MsgBox "2810にプリンタが変更されました。"
> End If
>End Sub
>
>Private Sub CommandButton5_Click()
> Dim oldPrinter As String
>
> ' 設定する前に今のプリンタを覚える
> oldPrinter = Application.ActivePrinter
> ' 任意のプリンタに変更
> Application.ActivePrinter = "Canon LBP5800 LIPS on Ne05:"
> ' 変更があったか確認
> If Application.ActivePrinter <> oldPrinter Then
> MsgBox "5800にプリンタが変更されました。"
> End If
>End Sub
VBAの基本的な事をもう少し学ばれたら良いかと思います。
そうすれば、今回の間違いにはすぐ気づかれたと思いますよ!!
|
|