我在下面使用此代码...
Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long)
Sub blink()
Sleep 500
ActiveSheet.Shapes("the_shape").Visible = False
Sleep 500
ActiveSheet.Shapes("the_shape").Visible = True
End Sub
我错过了什么吗?
答案 0 :(得分:1)
这很奇怪。添加DoEvents
解决了这个问题。我猜测Sleep
在Excel有机会隐藏形状之前暂停线程。
Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long)
Sub blink()
Sleep 500
ActiveSheet.Shapes("the_shape").Visible = False
DoEvents
Sleep 500
ActiveSheet.Shapes("the_shape").Visible = True
End Sub