On 4/29/2013 8:51 AM, Steve Blake wrote:
> On Friday, April 26, 2013 3:32:29 PM UTC-4, Dave Crash Dummy wrote:
>> Steve Blake wrote: > On Friday, April 26, 2013 2:35:25 PM UTC-4, Dave Crash Dummy wrote: >> Steve Blake wrote: > Okay, this should be a no brainer but I am have an issue with the following code working. > '################## DOES NOT WORK ######################## > > sub DisplayMessage(message) > Mresponse = ws.Popup (message, 30, "Information:", 1) > if (Mresponse = 2) then > msgbox "cancelled selected. Will now quit." > wscript.quit > elseif (Mresponse = -1) then > msgbox "Timed out. Will now quit." > wscript.quit > end if > msgbox "continuing to run" > end sub > > '################## DOES WORK ######################## > > sub DisplayMessage(message) > if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit > msgbox "continuing to run" > end sub > > Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement? > > Thanks. They both work for me if the ws object is set: Set ws=CreateObje
ct("WScript.Shell") -- Crash "I am not young enough to know everything." ~ Oscar Wil de ~ > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > Thanks Dave for the quick response. > > Interesting, I am setting WS exactly as noted below. > > Additional information: > I do get both sub's to display the message and it will timeout (if not selected) so, everything works from that point of view. > > However, it appears, once the message is processed (button clicked or timed out) the sub is exited and no code below that line [if (Mresponse... and bleow] is executed and control continues back to calling code. > > Additional variables: > Using Microsoft Internet Explorer 8 (Yes, I know.. I work for a very large company that does not allow computer changes) > Operating system is Windows XP Service pact 3 --> (Told you... they will not get with today's technologies) You did not say that you were running the code in a HTML file. I ran it as a VBS script. You are
disabling scripting after the result message (wscript.quit). The "continuing to run" message won't display because it is not continuing to run. Try commenting those lines out. -- Crash One man's weed is another man's wildflower.
>
> Sorry for the confusion... I only had that message line in as a troubleshooting line to see if the WS.Quit was executing. More specifically, I wanted to determine the jumping point from the SUB. As it is, that message is not (as expected) never displaying. But please keep in mind, that code snippet works. It is the other code snippet that I am trying to get to work that will identify �why� execution will stop. My issue occurs when I select "OK".
>
> So, in summary, I wanted to identify why execution was stopped. Therefore, I had (originally select case) if� ifelse� statements to identify the status. As it runs on my machine, I do NOT get any messages indicating Cancelled, Timed out, or continuing.
The code in question works for me in XP with IE8 installed. Try the
following for debugging purposes.
sub DisplayMessage(message)
Dim ws, Mresponse
Set ws = WScript.CreateObject("WScript.Shell")
Mresponse = ws.Popup (message, 3, "Information:", 1)
MsgBox "Mresponse=" & Mresponse, vbInformation 'for debugging
Wscript.Quit 'for debugging
if (Mresponse = 2) then
msgbox "cancelled selected. Will now quit."
wscript.quit
elseif (Mresponse = -1) then
msgbox "Timed out. Will now quit."
wscript.quit
end if
msgbox "continuing to run"
end sub
If you are still not locating the problem, try adding Option Explicit to
the top of the file and declare your variables to check for any variable
name misspellings.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)