|
我最近借鉴各位大侠之前成功案例做了个表格,在thisworkbookook 中公式如下,系统主要包含权限设定、自动保存和自动倒计时关闭工作薄,当手动关闭工作薄时不会出现任何警报内容,当在一定时间内不操作时会进行倒计时关闭表格,倒计时结束后会弹出“类型不拼配”报警,当调试时,程序停在 For y = 2 To UBound(arr, 2),但有个别电脑又可以正常运行,大部分电脑会弹出警报,不知道错在哪里,请高手指教,谢谢!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim y, arr
arr = Sheets("权限管理").Range("A1").CurrentRegion
For y = 2 To UBound(arr, 2)
Sheets(arr(1, y)).Visible = 2
Next y
On Error Resume Next
Application.OnTime EarliestTime:=TimeValue(Runtime), _
Procedure:="计时器", Schedule:=False
Application.OnTime EarliestTime:=TimeValue(PRuntime), _
Procedure:="倒计时", Schedule:=False
On Error GoTo 0
Application.DisplayAlerts = False
If Not Me.Saved Then Me.Save
End Sub
Private Sub Workbook_Open()
Sheet5.Select
Range("a1").Select
On Error Resume Next
Dim x, y, sr, arr
sr = Application.InputBox("请输入密码:", "登陆")
arr = Sheets("权限管理").Range("A1").CurrentRegion
For x = 2 To UBound(arr)
If Val(sr) = arr(x, 1) Then
For y = 2 To UBound(arr, 2)
If arr(x, y) = 1 Then
Sheets(arr(1, y)).Visible = -1
Sheets(arr(1, y)).Activate
End If
Next y
End If
Next x
Sheet5.Select
Range("a1").Select
Call 倒计时初始时间
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Call 倒计时起始时间设置
End Sub
|
|