Option
Explicit
Private
Declare
Sub
Sleep
Lib
"kernel32.dll"
( _
ByVal
dwMilliSeconds
As
Long
)
Private
mdtmTime
As
Date
Private
mblnClick
As
Boolean
Private
Sub
CommandButton1_Click()
Call
Application.OnTime(EarliestTime:=mdtmTime, _
Procedure:=
"prcTimer"
, Schedule:=
False
)
mblnClick =
True
Call
Unload(
Object
:=
Me
)
End
Sub
Private
Sub
UserForm_Activate()
Dim
lngIndex
As
Long
With
Controls.Add(bstrProgID:=
"MSComctlLib.ProgCtrl.2"
, _
Name:=
"ProgressBar1"
, Visible:=
True
)
.Left = 20
.Top = 20
.Width = 150
.Height = 30
.Max = 10
.Min = 0
.Value = 0
End
With
With
CommandButton1
.Width = 100
.Height = 20
.Top = Controls(
"ProgressBar1"
).Top + Controls(
"ProgressBar1"
).Height
.Left = Controls(
"ProgressBar1"
).Left
.Caption =
"Cancel_Close"
.BackColor = &H9400D3
End
With
mdtmTime = Now + TimeSerial(0, 0, 10)
Call
Application.OnTime(EarliestTime:=mdtmTime, Procedure:=
"prcTimer"
)
With
Controls(
"ProgressBar1"
)
For
lngIndex = .Min
To
.Max
DoEvents
Call
Sleep(1000&)
Call
.Refresh
Call
Repaint
.Value = lngIndex
If
Not
mblnClick
Then
_
Caption =
"Datei wird geschlossen in "
& _
.Max - lngIndex &
" Sec"
Next
End
With
End
Sub
Private
Sub
UserForm_QueryClose(Cancel
As
Integer
, CloseMode
As
Integer
)
Cancel = CloseMode <> vbFormCode
End
Sub