0

如标题所述,我所做的是:

Private Sub Workbook_Open()
    Dim ws As Worksheet
    Dim pwd As String
    pwd = "jfm" ' Put your password here
    For Each ws In Worksheets
    ws.Protect Password:=pwd, UserInterFaceOnly:=True
    Next ws
End Sub

但我想要的是:

  1. 创建一个计时器,比如说 5 秒
  2. 检查工作表是否未保护,5 秒后保护工作表。
  3. 如果工作表受到保护,则重复检查工作表是否不受保护。

提前致谢。

4

1 回答 1

0

就像是:

Dim StartTime As Double

StartTime = Timer

Dim i As Integer
Do Until False

    'if 5 seconds have elapsed, exit loop
    If CInt(Timer - StartTime) > 5 Then Exit Do

Loop

MsgBox "Finished after " & CInt(Timer - StartTime) & " seconds"
于 2012-12-29T12:22:35.197 回答