我正在尝试在UserForm打开后的某一段时间后执行Sub。访问启动后立即打开UserForm。有什么替代Application.OnTime的方法吗?因为它不适用于Access,而且似乎只适用于Excel。
这就是我的工作。
Private Sub UserForm_Activate()
Set objWSHShell = CreateObject("WScript.Shell")
DesktopDir = objWSHShell.SpecialFolders("Desktop") & "\"
InstallDir = Left(DesktopDir, 3) & "VICI"
VICIMxDir = InstallDir & "\VICI Mx.txt"
VICIFmDir = InstallDir & "\VICI Fm.txt"
VICIAnalyticsDir = InstallDir & "\VICI Analytics.txt"
With ListBox_Status
If FSO.FileExists(VICIMxDir) = True Then 'Both exist
.Column(1, 0) = "Ready"
Else
.Column(1, 0) = "Not Found"
End If
If FSO.FileExists(VICIFmDir) = True Then
.Column(1, 1) = "Ready"
Else
.Column(1, 1) = "Not Found"
End If
If FSO.FileExists(VICIAnalyticsDir) = True Then
.Column(1, 2) = "Ready"
Else
.Column(1, 2) = "Not Found"
End If
.Column(1, 3) = Environ("UserName")
End With
Application.OnTime Now + TimeValue("00:00:10"), "DB_BackUP"
Application.OnTime Now + TimeValue("00:00:20"), "RmvDBBackup"
End Sub发布于 2017-06-03 13:40:43
您可以使用Application.Wait
Private Sub UserForm_Activate()
waitTime (3000) ' 3 seconds
MyDeleyedMethod
End Sub
Function waitTime(ByVal millsec As Double)
Application.Wait (Now() + millsec / 24 / 60 / 60 / 1000)
End Function
Private Sub MydelayedMethod()
MsgBox ("hello")
End Sub实现这一结果的另一种方法是:
Private Sub UserForm_Activate()
Wait (3) ' 3 seconds
MyDeleyedMethod
End Sub
Sub Wait(seconds As Integer)
Dim now As Long
now = Timer()
Do
DoEvents
Loop While (Timer < now + seconds)
End Sub
Private Sub MyDeleyedMethod()
MsgBox ("hello")
End Subhttps://stackoverflow.com/questions/44342488
复制相似问题