landon_humphrey
New Member
- Joined
- Feb 22, 2010
- Messages
- 14
I have some code with the Application.Wait (Now + TimeValue("0:00:15")) added and it seems to work ok but I do not want to stop the entire program to stop running. This is being used in a condition based monitoring system that needs to run run run.
What I and trying to accomplish is to look at some values and if they change compare then wait a bit then verify then send a notification.
/*************Here is my Code *****************/
Private Sub Worksheet_Change(ByVal Target As Range)
'**********************************************************************
'**********Air % Alert Emailer*****************************************
' Add next group here
' [Line B1] Send e-mail
Dim ZedAE8
Dim commandAE8
Static OldValAE8
'only run this code if E8 has changed ()
If Range("E8").Text = ("#N/A") Then GoTo EndAB1 Else
If Range("E8").Value <> OldValAE8 And Range("E14").Value = 1 Then
OldValAE8 = Range("E8").Value
Range("H8") = OldValAE8
If Range("E8").Value <= 9 Then
Application.Wait (Now + TimeValue("0:00:15"))
If Range("E8").Value <= 9 And Range("E14").Value = 1 And Range("E11").Value <= ("600") Then
ZedAE8 = " [ Line# ] " & Range("E5").Text & " [ Green Light ] " & Range("E14").Text & " [ Air % ] " & Range("E8").Text
commandAE8 = "C:\sendemail\sendemail.exe -s 10.72.80.73 -f B1_oven@denso-diam.com"
commandAE8 = commandAE8 & " -t landon_humphrey@denso-diam.com -u B1 Air % Low Level Alert"
commandAE8 = commandAE8 & " -m B1 Oven Air % Level at or Below 9 " & ZedAE8 & " -q"
commandAE8 = commandAE8 & " -l C:\sendemail\logs\Alert_Emailer_Log.txt"
' Passing one long line to Scripting object. If there is need to add additional parameters, do it before.
Set wsShell = CreateObject("wscript.shell")
Set proc = wsShell.Exec(commandAE8)
Do While proc.Status = 0
'Wait until e-mail is sent...
Application.Wait (Now + TimeValue("0:00:01"))
Loop
Set wsShell = Nothing
Set proc = Nothing
MsgBox "Hello Mister Bibb The Alert Email Has Been Sent"
End If
End If
End If
EndAB1:
'End [Line B1]
End Sub
/*******************************************/
Any suggestions will be greatly appreciated
Respectively
Landon
What I and trying to accomplish is to look at some values and if they change compare then wait a bit then verify then send a notification.
/*************Here is my Code *****************/
Private Sub Worksheet_Change(ByVal Target As Range)
'**********************************************************************
'**********Air % Alert Emailer*****************************************
' Add next group here
' [Line B1] Send e-mail
Dim ZedAE8
Dim commandAE8
Static OldValAE8
'only run this code if E8 has changed ()
If Range("E8").Text = ("#N/A") Then GoTo EndAB1 Else
If Range("E8").Value <> OldValAE8 And Range("E14").Value = 1 Then
OldValAE8 = Range("E8").Value
Range("H8") = OldValAE8
If Range("E8").Value <= 9 Then
Application.Wait (Now + TimeValue("0:00:15"))
If Range("E8").Value <= 9 And Range("E14").Value = 1 And Range("E11").Value <= ("600") Then
ZedAE8 = " [ Line# ] " & Range("E5").Text & " [ Green Light ] " & Range("E14").Text & " [ Air % ] " & Range("E8").Text
commandAE8 = "C:\sendemail\sendemail.exe -s 10.72.80.73 -f B1_oven@denso-diam.com"
commandAE8 = commandAE8 & " -t landon_humphrey@denso-diam.com -u B1 Air % Low Level Alert"
commandAE8 = commandAE8 & " -m B1 Oven Air % Level at or Below 9 " & ZedAE8 & " -q"
commandAE8 = commandAE8 & " -l C:\sendemail\logs\Alert_Emailer_Log.txt"
' Passing one long line to Scripting object. If there is need to add additional parameters, do it before.
Set wsShell = CreateObject("wscript.shell")
Set proc = wsShell.Exec(commandAE8)
Do While proc.Status = 0
'Wait until e-mail is sent...
Application.Wait (Now + TimeValue("0:00:01"))
Loop
Set wsShell = Nothing
Set proc = Nothing
MsgBox "Hello Mister Bibb The Alert Email Has Been Sent"
End If
End If
End If
EndAB1:
'End [Line B1]
End Sub
/*******************************************/
Any suggestions will be greatly appreciated
Respectively
Landon