用以下測試找不到CreateObject("Wscript.shell").Popup 的訊息窗 ??
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Worksheet_Calculate()
If FindWindow("XLMAIN", "Auto Closed MsgBox") <> 0 Then msgbox "找到"
End Sub
Auto Closed MsgBox ====>訊息視窗的標題
還有用FindWindowJ找到後 3秒鐘自動關閉
這段巨集要怎麼寫??作者: stillfish00 時間: 2013-8-21 10:04
Private Declare Function MsgBoxTest Lib "user32" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As VbMsgBoxStyle, _
ByVal wlange As Long, _
ByVal dwTimeout As Long) As Long
Private Sub Worksheet_Calculate()
Application.DisplayStatusBar = False
Dim sStr$
Dim ZZ As Range
sStr = ""
sStr2 = ""
For Each ZZ In Range("c2:c111")
If Not IsError(ZZ) Then
If Range("R26").Value = 2 Then Range("U26").Value = 1
If Range("Q26").Value = 1 And Range("U26").Value = 1 And flag = True Then
M = Round(ZZ - ZZ.Offset(, 26), 2)
If M >= ZZ.Offset(, 2) Then
If sStr <> "" Then sStr = sStr & Chr(10)
sStr = sStr & "===> " & Cells(ZZ.Row, 2).Value & "=====> " & Round(ZZ - ZZ.Offset(, 26), 2) & "===>" & ZZ.Offset(, 26) & "===>" & ZZ
Application.EnableEvents = False
ZZ.Offset(, 26) = ZZ
Application.EnableEvents = True
End If
If M <= -ZZ.Offset(, 2) Then
If sStr2 <> "" Then sStr2 = sStr2 & Chr(10)
sStr2 = sStr2 & "===> " & Cells(ZZ.Row, 2).Value & "=====> " & Round(ZZ - ZZ.Offset(, 26), 2) & "===>" & ZZ.Offset(, 26) & "===>" & ZZ
Application.EnableEvents = False
ZZ.Offset(, 26) = ZZ
Application.EnableEvents = True
End If
End If
End If
Next
If sStr <> "" Then
MsgBoxTest 0, "", "", sStr, 0, 2500
'----------------
If sStr2 = "" Then
If Range("R26").Value = 1 Then Range("U26").Value = 2
' Range("Q26").Value = 2
' Application.OnTime Now + TimeValue("00:00:15"), "fff"
End If
'----------------------------------------
End If
If sStr2 <> "" Then
MsgBoxTest 0, "", "", sStr2, 0, 2500
If Range("R26").Value = 1 Then Range("U26").Value = 2