Makro läßt sich nicht stoppen
23.08.2007 20:28:00
Born
beim Versuch, eine Fortschrittsleiste zu basteln stoße ich auf das Problem,
daß sich der Prozess, wenn einmal gestartet mit der esc-Taste nciht mehr
abbrechen läßt. Kann mir vielleicht einer erklären, warum, oder noch besser,
wie ich das ändern kann?
Hier der Code:
Option Explicit
Sub ShowDialog()
Load ProgressDlg
ProgressDlg.Show
End Sub
Sub Main()
Dim i As Long, tot As Long
tot = 100
ProgressDlg.Caption = "Prosessing data, please wait..."
For i = 1 To tot
Range("HD2:HD327").Copy
Range("HN2") = Range("HN2") + 1
Cells(2, 235 + i).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If i Mod 1 = 0 Then ProgressBar i / tot
' do something
Next i
Unload ProgressDlg
End Sub
Sub ProgressBar(PctDone As Single)
With ProgressDlg
.lblDone.Width = PctDone * (.lblRemain.Width - 2)
.lblPct.Caption = Format(PctDone, "0%")
End With
'The DoEvents statement is responsible for the form updating
DoEvents
End Sub
Danke,
Born